There is nothing superfluous in determining which exception is selected as the result of an operation. It really fits perfectly with Roy's naming convention, given:
SomeMethod_ExpectionalState_ThrowsInvalidOperationException SomeMethod_ExceptionalState_ThrowsArgumentNullException
You get important information about your type of excluded code type. However, when you have a classic happy path test, the usefulness of some parts of the name is subjective. Consider:
SomeMethod_DependencyReturnsCorrectResult_ReturnsResult SomeMethod_WhenNothingSpecialHappens_ReturnsResult SomeMethod_EverythingElseWorked_WorksToo
What information do such names carry? Pretty little. ReturnsResult essentially means that it works. NothingSpecialHappens also pretty vague information. In such cases, dropping part of the name may be justified.
Please note, however, instead, it might be worth considering changing the name rather than completely discarding part of it (for example, ReturnsResult may be replaced by a less vague ReturnsEntityFromDatabase or ReturnsSerializedValue ).
Finally, do not follow Roy blindly - treat him as recommendations , not conventions. Conventions are rarely suitable for all possible situations, and this is no different.
source share