What are the best practices to test PowerShell cmdlets? The cmdlets I'm testing are writing 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?

  • 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.

  • 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.

  • Thanks, any hints about security testing with PS?
    – Ahmet
    Oct 20 '11 at 17:17
  • 1
    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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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