1 KiB
1 KiB
Do
- Name your files .tests.ps1
- Keep tests simple
- Test only what you need
- Reduce dependencies
- Be sure to tag your Describe blocks with "inner" and "outer"
- Make sure that Describe/Context/It descriptions are useful
- The error message should not be the place where you describe the test
- Use "Context" to group tests
- Multiple Contexts can help you group your test suite into logical sections
- Use BeforeAll/AfterAll/BeforeEach/AfterEach instead of custom initiators
- Use Try-Catch for expected errors and check $_.fullyQualifiedErrorId
- Loop It blocks for checking multiple properties
- Use code coverage functionality where appropriate
- Use Mock functionality when you don't have your entire environment
- Avoid free code in a Describe block
- Use
[Before|After][Each|All]
see Free Code in a Describe block
- Use
Don't
- Have too many evaluations in a single It block
- The first "Should" failure will stop that block
- Don't use "Should" anywhere but within an "It" Block