FIRST - alexanderteplov/computer-science GitHub Wiki
- Fast
- Isolated/Independent
- Repeatable
- Self-validating
- thorough
The developer shouldn’t hesitate to run the unit tests. Tests should run in a matter of seconds.
- For any given unit test, for its environment variables or for its setup.
- SHould be divided into three parts according to AAA pattern:
- Arrange. All the data should be provided to the test when you’re about to run the test and it should not depend on the environment you are running the tests.
- Act. Invoke the actual method under test.
- Assert. At any given point, a unit test should only assert one logical outcome, multiple physical assertions can be part of this physical assertion, as long as they all act on the state of the same object.
- tests should be repeatable and deterministic, their values shouldn’t change based on being run in different environments.
- Each test should set up its own data and should not depend on any external factors to run its test
You shouldn’t need to check manually, whether the test passed or not.
- Should cover all the happy paths
- Try covering all the edge cases, where the author would feel the function would fail.
- Test for illegal arguments and variables.
- Test for security and other issues
- Test for large values, what would a large input do their program.
- Should try to cover every use case scenario and not just aim for 100% code coverage.