[This post was split off from here:
https://coderanch.com/t/777818/java/Mocking#3555275] Some of the reasoning behind using underscores and making test names more readable:
- Tests should test a story - they should have a beginning, a middle, and an end. If you use JUnit nested classes, you can also structure the story told in the test report:
RestaurantTest
OperatingHours
should be open between opening time and closing time
should not be open before opening time
should not be open after closing time
Menu
should include drinks
should include desserts
should include lunch specials
should include daily specials
Reservations
should allow reservation for current day
should allow reservation for future date
- If your tests are going to tell a story, the test names should give you a "overall" view of that story.
- Tests should serve as examples for how to use the class under test. Tests should help you understand the API and its design.
- Tests should help you quickly find where problems are happening in your code