mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 04:36:39 +00:00
1.5 KiB
Executable File
1.5 KiB
Executable File
Do
- Name your files .tests.ps1
- Keep tests simple
- Test only what you need
- Reduce dependencies
- Be sure to tag your
Describeblocks based on their purpose- Tag
CIindicates that it will be run as part of the continuous integration process. These should be unit test like, and fast. - Tag
Featureindicates a higher level feature test (we will run these on a regular basis), for example, tests which go to remote resources, or test broader functionality - Tag
Scenarioindicates tests of integration with other features (these will be run on a less regular basis and test even broader functionality than feature tests.
- Tag
- Make sure that
Describe/Context/Itdescriptions are useful- The error message should not be the place where you describe the test
- Use
Contextto group tests- Multiple
Contextblocks can help you group your test suite into logical sections
- Multiple
- Use
BeforeAll/AfterAll/BeforeEach/AfterEachinstead of custom initiators - Use Try-Catch for expected errors and check $_.fullyQualifiedErrorId (don't use
should throw) - Use
-testcaseswhen iterating over multipleItblocks - Use code coverage functionality where appropriate
- Use
Mockfunctionality when you don't have your entire environment - Avoid free code in a
Describeblock- 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
Shouldfailure will stop that block
- The first
Shouldbe used in anItBlock