Is summary necessary in unit test method

后端 未结 8 877
忘掉有多难
忘掉有多难 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:56

    I think the long descriptive name is more important than the XML comment. Since the unit test isn't going to be part of an API, you don't need the XML comment.

    For Example:

    [TestMethod]
    public void FormatException_Should_Thrown_When_Parse_CountryLine_Containing_InvalidNumber()
    {
      ...
    }
    

    is more useful than:

    ///
    /// Exception Should Thrown When Parse CountryLine Containing InvalidNumber
    ///
    [TestMethod]
    public void Test42()
    {
      ...
    }
    

    XML Comments should be used for documenting APIs and frameworks.

提交回复
热议问题