Following TDD will ensure that virtually all code is covered, but can result in an alarming amount of test code, thus presenting a daunting management problem
Writing dirty tests is equivalent to, if not worse than, writing no tests at all; the dirtier tests are, the harder they are to maintain. Hence, we have to strive to write clean tests - test code is just as important as production code
Unit tests keep our code flexible, maintainable, and reusable. Without tests, every change is a potential bug. Tests enable change
A clean test is a readable test, and clarity, simplicity, and density of expression (say a lot with very little) make tests readable. Notice that efficiency is not a key priority since tests will run in a test environment (and not a production environment)
Minimise the number of asserts in a test, but don’t be afraid to put more than 1. Try to test a single concept in each test function
Clean tests also follow the FIRST acronym: Fast (to run), Independent (of other tests), Repeatable (in any environment), Self-Validating (with a boolean output), and (written in a) Timely (fashion)
Relevance to TEAMMATES:
We aim to have a high test coverage of every component, and hence will inevitably run into the management problem above. The problem is made worse by the fact that our contributors can come from anywhere and may have very diverse backgrounds and experiences. Therefore, writing and enforcing clean tests is even more important to ensuring the maintainability of TEAMMATES
Book: Clean Code Chapter: 9 (Unit Tests)
Summary:
Following TDD will ensure that virtually all code is covered, but can result in an alarming amount of test code, thus presenting a daunting management problem
Writing dirty tests is equivalent to, if not worse than, writing no tests at all; the dirtier tests are, the harder they are to maintain. Hence, we have to strive to write clean tests - test code is just as important as production code
Unit tests keep our code flexible, maintainable, and reusable. Without tests, every change is a potential bug. Tests enable change
A clean test is a readable test, and clarity, simplicity, and density of expression (say a lot with very little) make tests readable. Notice that efficiency is not a key priority since tests will run in a test environment (and not a production environment)
Minimise the number of asserts in a test, but don’t be afraid to put more than 1. Try to test a single concept in each test function
Clean tests also follow the FIRST acronym: Fast (to run), Independent (of other tests), Repeatable (in any environment), Self-Validating (with a boolean output), and (written in a) Timely (fashion)
Relevance to TEAMMATES: We aim to have a high test coverage of every component, and hence will inevitably run into the management problem above. The problem is made worse by the fact that our contributors can come from anywhere and may have very diverse backgrounds and experiences. Therefore, writing and enforcing clean tests is even more important to ensuring the maintainability of TEAMMATES