Is summary necessary in unit test method

后端 未结 8 871
忘掉有多难
忘掉有多难 2021-02-07 07:01

Since the naming of a unit test method makes its purpose more meaningful, is it necessary to add a summary to a unit test method?

Example:

/// 

        
8条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-07 07:57

    An XML comment is totally unnecessary if you have a descriptive method name. And it's a must for unit-test methods.

    You're already on the right track having a descriptive test method name. (Many agile and TDD practitioners believe that a test method should include "should", e.g. as shown in link text this blog post.

    Personally, I like method names like this:

    MyClass_OnInvalidInput_ShouldThrowFormatException()
    

    But that's merely my personal preference.

提交回复
热议问题