💡 Consider the following three laws before writing Unit Test :
1- You may not write production code until you have written a failing unit test.
2- You may not write more of a unit test than is sufficient to fail, and not com-piling is failing.
3- You may not write more production code than is sufficient to pass the currently failing test.
#CleanCode #UnitTest #TDD
1- You may not write production code until you have written a failing unit test.
2- You may not write more of a unit test than is sufficient to fail, and not com-piling is failing.
3- You may not write more production code than is sufficient to pass the currently failing test.
#CleanCode #UnitTest #TDD
Test code is just as important as production code❗️
It is not a second-class citizen .
It requires thought, design, and care .
It must be kept as clean as production code .
#CleanCode #UnitTest
It is not a second-class citizen .
It requires thought, design, and care .
It must be kept as clean as production code .
#CleanCode #UnitTest
What makes a clean test❓
Three things : Readability, readability, and readability.
Read-ability is perhaps even more important in unit tests than it is in production code .
What makes tests readable ❔
The same thing that makes all code readable :
clarity, simplicity & density of expression .
#CleanCode #UnitTest
Three things : Readability, readability, and readability.
Read-ability is perhaps even more important in unit tests than it is in production code .
What makes tests readable ❔
The same thing that makes all code readable :
clarity, simplicity & density of expression .
#CleanCode #UnitTest
What is Unit Test ❓
A unit test is a piece of a code (usually a method) that invokes another piece of code and checks the correctness of some assumptions afterward. ✅
If the assumptions turn out to be wrong, the unit test has failed. ❌
A unit is a method or function.
#UnitTest
@ProgrammingTip
A unit test is a piece of a code (usually a method) that invokes another piece of code and checks the correctness of some assumptions afterward. ✅
If the assumptions turn out to be wrong, the unit test has failed. ❌
A unit is a method or function.
#UnitTest
@ProgrammingTip
Properties of a good unit test ✅
A unit test should have the following properties :
1️⃣ It should be automated and repeatable.
2️⃣ It should be easy to implement.
3️⃣ It should be relevant tomorrow.
4️⃣ Anyone should be able to run it at the push of a button.
5️⃣ It should run quickly.
6️⃣ It should be consistent in its results.
7️⃣ It should have full control of the unit under test.
8️⃣ It should be fully isolated (runs independently of other tests).
9️⃣ When it fails, it should be easy to detect what was expected and determine how to pinpoint the problem.
#UnitTest #Tips
@ProgrammingTip
A unit test should have the following properties :
1️⃣ It should be automated and repeatable.
2️⃣ It should be easy to implement.
3️⃣ It should be relevant tomorrow.
4️⃣ Anyone should be able to run it at the push of a button.
5️⃣ It should run quickly.
6️⃣ It should be consistent in its results.
7️⃣ It should have full control of the unit under test.
8️⃣ It should be fully isolated (runs independently of other tests).
9️⃣ When it fails, it should be easy to detect what was expected and determine how to pinpoint the problem.
#UnitTest #Tips
@ProgrammingTip