[Time saver] Writing tests when you have long list of parameters #7734
wsmelton
started this conversation in
Contributors
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The main pattern we use now for the unit test we do with dbatools and Pester is the following:
We steer away from using
Get-Command
anymore as it has too much overhead when we have hundreds of tests to run through in Appevyor. The$knownParameters
is where you will place the parameters the command has support for. We do this so we can make sure we are monitoring the parameters that get added in a given command. (If you see a command that needs a new parameter make sure to create a feature request for it 😉)A small function I keep in my profile for writing tests so I can more easily get the initial list of parameters is to reuse a portion of what our test does as well:
Example:
Get-CommandParameterList Connect-DbaInstance | clip
-- this will copy the list to the clipboard and then I can simply paste it right into the test.Beta Was this translation helpful? Give feedback.
All reactions