Best/cleaner way to run same test against multiple instances. #2950
OranguTech
started this conversation in
General
Replies: 1 comment
|
I'd recommend using data-driven tests. It would scale your tests to match the number of instance*databases and identity each combination in the test name/path. E.g. Describe "SQL Checks" {
BeforeDiscovery {
$DBConnections = ... # Define/get one or more instance names
}
Context 'Instance <_>' -ForEach $DBConnections {
BeforeDiscovery {
$currentConn = $_ # not required, just to simplify explanation
$Databases = Get-DbaDatabase $currentConn -Database @('ACMECustomers', 'ACMEProducts')
}
Context 'Database <_.Name>' -ForEach $Databases {
BeforeAll {
$currentDb = $_ # not required, just to simplify explanation
}
It 'Is compatible with Version170' {
$compat = $currentDb | Get-DbaDbCompatibility
$compat.Compatibility | Should-Be 'Version170'
}
}
}
}Side-note: In Pester v6 you could replace |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hello again, I have a test like this:
This works fine against a single instance, but if I run that against multiple endpoints, the result is an array, and then the test fails.
Is there a more "pester native" way to say "Run this test against every instance I hand you" other than
foreach?But that's
1 - A bit less clear, and semantically just feels "ugly".
2 - If one instance fails, it's not clear which instance, just that at least one did.
(This is currently using Pester v5)
All reactions