Better QA: Learning from unit testing standards
What is unit testing?
Understanding the concept of unit testing
- Tests should be independent – This is the basic principle, there should not be any dependency among the test cases. This is important because one test case result should not impact subsequent cases.
- In automation, we should make sure that there is no dependency such as environment setting, creating instances of shared resources and cleaning up the same.
- Tests should be deterministic – A test should either pass or fail all the time. The worst test is the one that passes some of the time. We should always have a definite reason if the test fails and when correcting that, the test should always pass.
- Tests should hold good for pass/fail cases – By this, I mean that a test should fail when it meant to fail. Put assertions carefully and run the test for a fail condition also.
- Tests should be self-validating – This means that the test should itself determine that the output is expected or not. There should not be any manual interpretation.
- Repeatable – Test should produce the same output every time it runs. This can be accomplished by making them isolated and independent.
How unit testing is performed