Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What are the best practices to test PowerShell cmdlets? The cmdlets I'm testing are writting data into a DB.

I am currently using:

  1. Pairwise to go through most of the combinations
  2. Check that get == set

What else could be used?


share|improve this question
up vote 3 down vote accepted
  • Since you are referring to writing data to DB. Please check below scenarios as well
    1. Capturing Errors due to constraints, data loading failures (data type mismatch), missing columns in inserts
    2. Logging of errors that you have received
    3. Do you need to check on retry logic in case if it fails for deadlock ?
    4. How do you pass different test data - is it hardcoded or dynamic (using queries for test data generation). Use Realtime production data
    5. If you are running multiple transactions on tables, does it get rolled back. Is it atomic ?

If you can provide more details on cmdlet functionality - we can discuss further or more areas that can be covered.

share|improve this answer
Thanks, that sounds like wise advises for DB testing. I am currently more interested by the PS side (data validation, management of SQL errors, SQL injection). – Ahmet Oct 20 '11 at 17:16

A few things I might check since this is PowerShell and the DB

  • v1 against v2 (if you are expected to support it)
  • various accounts, unless you expect them all to run Admin
  • External libraries, we run a few of our own scripts but load up extra library files in the profile you may want to test that what is loaded is loaded
  • deadlock conditions
  • database transactions, if you run transactions you could check that these succeed/or fail if you want negative tests

Without knowing more that's what I'd check first off.

share|improve this answer
Thanks, any hints about security testing with PS? – Ahmet Oct 20 '11 at 17:17
Haven't done much with that, although if you are going to communicate with other servers look into CredSSL. – MichaelF Oct 20 '11 at 17:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.