Additional test attributes(可以在测试方法上使用的属性)
As you have seen, the unit-testing subsystem within Visual Studio uses attributes to identify test cases.
A number of additional properties can be set to provide further information about a test case. This
information is then accessible either via the Properties window associated with a test case or within the
other test windows. This section goes through the descriptive attributes that can be applied to a test method.

Description(描述测试用例的额外信息)
Because test cases are listed by the test method name, a number of tests may have similar names, or names
that are not descriptive enough to indicate what functionality they test. The Description attribute, which
takes a String as its sole argument, can be applied to a test method to provide additional information about
a test case.

Owner(描述测试用例的作者或所属测试用例)
The Owner attribute, which also takes a String argument, is useful for indicating who owns, wrote, or is
currently working on a particular test case.

Priority(描述测试用例的优先级,该属性不会显示在测试框架中)
The Priority attribute, which takes an Integer argument, can be applied to a test case to indicate the
relative importance of a test case. Though the testing framework does not use this attribute, it is useful for
prioritizing test cases when you are determining the order in which failing, or incomplete, test cases are
resolved.

TestCategories(测试分类:可将多个测试用例归为一类,或则将一个测试用例归到多类中,测试框架可以选择按类别显示)
The TestCategory attribute accepts a single String identifying one user-defied category for the test. Like
the Priority attribute, the TestCategory attribute is essentially ignored by Visual Studio but is useful
for sorting and grouping related items together. A test case may belong to many categories but must have a
separate attribute for each one.

WorkItems
The WorkItem attribute can be used to link a test case to one or more work items in a work-item tracking
system such as Team Foundation Server. If you apply one or more WorkItem attributes to a test case, you
can review the test case when making changes to existing functionality. You can read more about Team
Foundation Server in Chapter 57, “Team Foundation Server.”
Ignore
You can temporarily prevent a test method from running by applying the Ignore attribute to it. Test
methods with the Ignore attribute will not be run and will not show up in the results list of a test run.

Timeout(超时时间,毫秒为单位,但测试用例运行时间超过指定时间后认为测试失败)
A test case can fail for any number of reasons. A performance test, for example, might require a particular
functionality to complete within a specifid time frame. Instead of the tester writing complex multithreading
tests that stop the test case when a particular timeout has been reached, you can apply the Timeout attribute
to a test case with a timeout value in milliseconds, as shown in the following code. This ensures that the test
case fails if that timeout is reached.

[TestMethod()]
[Owner("Mike Minutillo")]
[Description("Tests the functionality of the Current Status Method")]
[Priority(3)]
[Timeout(10000)]
[TestCategory("Financial")]
public void CurrentStatusTest()
{
Subscription target = new Subscription();
Subscription.Status actual;
actual = target.CurrentStatus;
Assert.AreEqual(Subscription.Status.Temporary, actual,
"Subscription.CurrentStatus was not set correctly.");
}

Code Illustrate
    This snippet augments the original CurrentStatusTest method with some of these attributes to illustrate
their usage. In addition to providing additional information about what the test case does and who wrote it,
this code assigns the test case a priority of 3 and a category of "Financial" . Lastly, the code indicates that
this test case should fail if it takes more than 10 seconds (10,000 milliseconds) to execute.

单元测试方法属性(Unit Test Method Attribute)的更多相关文章

  1. 如何获取类或属性的自定义特性(Attribute)

    如何获取类或属性的自定义特性(Attribute) 问题说明: 在ActiveRecord或者其他的ORM等代码中, 我们经常可以看到自定义特性(Attribute)的存在(如下面的代码所示) [Pr ...

  2. spring 单元测试方法及其错误整理

    spring 单元测试及其错误整理 目录: NO1 spring单元测试方法 - NO1.1 pom.xml文件中确认有下面依赖 - NO1.2 在需要测试的类上,或者新建的测试类上添加注解 - NO ...

  3. C#导出Excel按照指定格式设置单元格属性值

    最近项目中一直在写XML.Table.Excel之间的转化.之前一直都是不考虑格式的导出,今天给出一个格式,让按照格式导出,还真把我这新手为难了一翻,网上给出的资料基本一样.为了一个单元格文字变色纠结 ...

  4. java 面向对象(十七):单元测试方法

    * Java中的JUnit单元测试 * * 步骤: * 1.中当前工程 - 右键择:build path - add libraries - JUnit 4 - 下一步 * 2.创建Java类,进行单 ...

  5. WebApi 2:属性路由 [Route()],attribute routing

    原文:http://www.asp.net/web-api/overview/web-api-routing-and-actions/attribute-routing-in-web-api-2 属性 ...

  6. 熟悉Junit单元测试方法

    定义: JUnit是一个Java语言的单元测试框架.它由Kent Beck和Erich Gamma建立,逐渐成为源于Kent Beck的sUnit的xUnit家族中最为成功的一个. JUnit有它自己 ...

  7. 修正线性单元(Rectified linear unit,ReLU)

    修正线性单元(Rectified linear unit,ReLU) Rectified linear unit 在神经网络中,常用到的激活函数有sigmoid函数f(x)=11+exp(−x).双曲 ...

  8. 软件测试第二次作业:初识JUNIT单元测试方法

    软件测试有很多分类,从测试的方法上可分为:黑盒测试.白盒测试.静态测试.动态测试   从软件开发的过程分为:单元测试.集成测试.确认测试.验收.回归等. 在众多的分类中,与开发人员关系最紧密的莫过于单 ...

  9. 软件测试:第二次作业(JUnit单元测试方法)

    一.JUnit是什么? JUnit是由 Erich Gamma 和 Kent Beck 编写的一个回归测试框架(regression testing framework).JUnit测试是程序员测试, ...

随机推荐

  1. c#用UpdatePanel实现接局部刷新

    通常我们看到局部刷新就会想到Ajax,但是我今天要说的是c#的一个控件,只要把服务器按钮和要刷新的区域放在该控件内就能实现局部刷新. 当然它必须和ScriptManager控件一起使用. Update ...

  2. 记一下STL的一个题

    A. Diversity time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  3. Strassen优化矩阵乘法(复杂度O(n^lg7))

    按照算法导论写的 还没有测试复杂度到底怎么样 不过这个真的很卡内存,挖个坑,以后写空间优化 还有Matthew Anderson, Siddharth Barman写了一个关于矩阵乘法的论文 < ...

  4. hdu 3717 二分+队列维护

    思路:已知当前的总长度和为len,当前的伤害为sum,伤害次数为 num.那么对下一个点的伤害值sum=sum+2*len+num: 这个是通过(x+1)^2展开化简就能得到. #include< ...

  5. 《c程序设计语言》读书笔记-删除字符串中匹配的字符

    #include <stdio.h> #include <string.h> #define Num 10 int main() { int c,i,j = 0,m,n = 0 ...

  6. poj 2187 Beauty Contest(二维凸包旋转卡壳)

    D - Beauty Contest Time Limit:3000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u ...

  7. dedeCMS常用功能板块记忆

    1.自动调到栏目第一个子栏目 <script> {dede:channel type='son' row='1'} window.location.href='[field:typelin ...

  8. Access数据库 INSERT INTO 失败

    一次操作Access数据库,插入一条数据,总是失败,如下: 通过赋值,一个字段一个字段的排查,最终确定是UserAge字段处有问题. 最初,UserAge字段是 %d 类型的,赋值20,可成功插入数据 ...

  9. VIM使用系列: 复制并移动文本

    1 5. 复制并移动文本 *copy-move* 2 3 *quote* 4 "{a-zA-Z0-9.%#:-"} 指定下次的删除.抽出和放置命令使用的寄存器 5 {a-zA-Z0 ...

  10. 最简单的基于FFmpeg的AVDevice例子(读取摄像头)【转】

    转自:http://blog.csdn.net/leixiaohua1020/article/details/39702113 版权声明:本文为博主原创文章,未经博主允许不得转载.   目录(?)[- ...