A set of a unit tests for a project 3+ years old, now fail. It seems the tests themselves have become out of date, and I've wasted time trying to find non existent bugs.

To prevent this happening again, I will update the unit tests to correct values, and want to document why the input data is and expected results are correct.

Any advice and recommendations on best practices to do this, to make it easier for the next guy on this project would be very helpful right now.

2 Answers 2


Carefully name tests reflecting requirement in the form of input data & expected result.

I have been in similar situation but for integration UI tests, where it really helped us when we started carefully naming the tests with single specific requirement although sometimes names were very long.

We made sure that test name should unambiguously reflect an single direct requirement(or sub requirement) which should be understandable to all team members.

When we open an old test and if we really need to dig inside the test method to understand it, then its clear indication we need to rename it correctly to reflect input & output w.r.t. to an requirement.

Example: CalcShippingCharges_OrdValGrtThan35_FreeShipping


For the unit testing best practices - I would recommend you reading xUnit Test Patterns: Refactoring Test Code book by Gerard Meszaros.

This book is basically a collection of best practices, patterns among with test anti-patterns and smells.

Also, check the book site.

Don't be afraid of XUnit word in the title, these patterns are applicable to any kind of unit testing framework that you use.

  • 2
    I appreciate your answer, but you can't just post a bunch of links. From the help center: "Always quote the most relevant part of an important link […]". Please add a summary that answers the OP's question.
    – beatngu13
    Sep 15, 2019 at 20:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.