Testing rules
Learn about the testing rules.
We'll cover the following...
Below are the general rules that we should follow during testing:
Rules
-
You must write the test as soon as you write the code. Writing the test some days after writing the code is useless because it’s easy to forget the choices you made (choices that you need to test).
-
The test must fail before you write the code and succeed when you have written the code. Otherwise, you can not be sure whether the test is correctly testing your code and that it is your code that enables the test to succeed. If you are fixing a bug, you want to be sure that you did not accidentally, systematically reproduce it.
-
A failing test is a good thing! A failing test protects us from a regression! The important thing to remember is that the tests should not fail randomly. ...