Junior — Middle
Have you ever encountered cases where you faced poor quality or poorly written tests?
sobes.tech AI
Answer from AI
Yes, I have encountered poorly written tests. Usually, such tests have the following issues:
- Lack of clear structure and description of what is being tested.
- Tests are too fragile and break with minor code changes.
- Use of magic values without explanations.
- Lack of isolation, where tests depend on each other or external resources.
For example, a test that checks a function but depends on the state of a database can give false results. In such cases, it is important to rewrite the tests, make them more modular and independent, use mock objects, and clearly document the purpose of the test.