A common practice is to prefix test method names in JUnit with "test". But in the past few years, some people have changed this to the "must" prefix.
If I want to test client creation in a database, I would usually call the testCustomerCreation method. However, some people will call "shouldCreateCustomer".
It is a lot of personal taste when I am the only person in the project or when all other project participants agree with me. But when / where it is not, some discrepancies or inconsistent mixes appear.
I read an article somewhere in a guy who called his methods, such as "testShouldCreateCustomer", and for this reason decided to abandon the prefix "test". But actually it is not a prefix of "test", it used "testShould" and changed to "should". Obviously, this did not convince me.
I personally am strongly inclined to adhere to the prefix "test", because method names usually begin with verbs in infinitive form ("get", "set", "add", "remove", "clear", "send", "receive", " open "," close "," read "," write "," create "," list "," pop "," print ", etc., so this is a" test "). So, the prefix of the method name with the name "should" makes it very strange for me, it looks wrong.
So what is the real reason to use "should" instead of "test"? What are the advantages and disadvantages?
java junit naming-conventions junit4
Victor stafusa
source share