有必要在总结单元测试方法 [英] Is summary necessary in unit test method

查看:153
本文介绍了有必要在总结单元测试方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于单元测试方法的命名使得它的目的更有意义的,是有必要的总结添加到单元测试方法



?例如:

  ///<总结>当一个给国家数据线包含了无效的数字
///检查Fo​​rmatException应该抛出。
///< /总结>
[TestMethod的]
公共无效FormatException_Should_Thrown_When_Parse_CountryLine_Containing_InvalidNumber()
{

}


解决方案

我觉得长描述性的名称比XML注释更重要。由于单元测试是不会成为一个API的一部分,你不需要XML注释



例如:

  [TestMethod的] 
公共无效FormatException_Should_Thrown_When_Parse_CountryLine_Containing_InvalidNumber()
{

}

不止有用:

  ///<总结>当解析CountryLine含InvalidNumber 
///<
///异常应抛出该异常; /总结>
[TestMethod的]
公共无效Test42()
{

}

XML注释应该用于记录API和框架。


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:

/// <summary>
/// Check the FormatException should be thrown when a give country data line contains a invalid number.
/// </summary>
[TestMethod]
public void FormatException_Should_Thrown_When_Parse_CountryLine_Containing_InvalidNumber()
{
  ...
}

解决方案

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:

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

XML Comments should be used for documenting APIs and frameworks.

这篇关于有必要在总结单元测试方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆