Better QA: Learning from unit testing standards

Shubham Kumar Published on 09 July 2020

What is unit testing?

Understanding the concept of unit testing

  1. 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.
  2. 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.

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

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

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

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