Which of the following names of test methods do you think to be the best?
(Notice that we could leave out “payment_” from the last name if it is clear from the context, i.e. from the fixture [a fancy name for test class] name.)
According to the holy book of Clean Code, the code should make visible the intent as much as possible. According to the testing guru Kent B., a test should be telling a story to its reader – a story about how the code should be used and function. According to these two and my own experiences from reading a lot of (test) core written by other people, the last one is absolutely the best. However you have the right to disagree and discuss 🙂
PS: I firmly believe that calling a test method “test()” should be punishable.
Calling it “test()” is a punishable offence is sweden according to article #255.FF in the Offensive Coding Act.
I don’t know why you opted to use camel case for the first 3, then abandon it for the 4th. 3rd one is perfectly good for a passing test where the user id is unknown (i.e. you haven’t said what the test does before you ask the question).
I used CamelCase for the first three because that is the “old” standard in Java. Now I tend to use the more readable underscored names.
> you haven’t said what the test does before you ask the question
Thank you for pointing out the difference between 3. and 4. so well.