java unit test naming convention code example
Example: unit test naming convention
MethodName_StateUnderTest_ExpectedBehavior
Example: add_twoPositiveIntegers_returnsTheirSum()
Variant: Add_TwoPositiveIntegers_ReturnsTheirSum()
Note: This is not camel case, so the question of whether to start each new chunk with a capital is up to you.
MethodName_ExpectedBehavior_StateUnderTest
Example: add_returnsTheSum_ofTwoPositiveIntegers()
Variant: Add_ReturnsTheSum_OfTwoPositiveIntegers()
itShouldExpectedBehaviorConnectingWordStateUnderTest
Example: itShouldCalculateTheSumOfTwoPositiveIntegers()
Variant: testItCalcultesTheSumof..
givenStateUnderTest_whenMethodAction_thenExpectedBehavior
Example: givenTwoPostiveIntegers_whenAdded_thenTheyShouldBeSummed
Variant: givenTwoPositiveIntegerWhenAddedThenTheyShouldBeSummed()