DEV Community

Discussion on: Clean Code with Unit Tests: Tips and tricks for keeping your test suites clean

Collapse
 
ashleyjsheridan profile image
Ashley Sheridan

For me it depends on what the test is trying to achieve. If the code under test is doing more than it strictly should, then sometimes the tests have to be tied more into inputs and outputs. This can help when that functionality is refactored out, but I think it's important to get some test coverage before a refactor if there wasn't any coverage before, as it's all too easy to introduce bugs when refactoring complex code.

However, I agree completely on your point of avoiding calculating values in tests. Having pre-calculated values that test branching though is ok.