Nunit标头中的Jira票证参考 [英] Jira Ticket reference in Nunit header

查看:68
本文介绍了Nunit标头中的Jira票证参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在创建具有相应的Jira故事的Nunit测试.我们一直在将票证引用放在测试名称中,但是是否应该考虑使用约定或Nunit属性,而这将是代替该引用的有用或有组织的地方?

We are creating Nunit tests which have corresponding Jira stories. We have been putting the ticket reference in the test name, but is there a convention or Nunit attribute that we should consider using instead which would be a useful or organised place for putting this reference instead?

推荐答案

许多人为此目的使用[Description]属性.

Many folks use the [Description] attribute for this purpose.

另一种选择是使用[TestOf].虽然它旨在指定要测试的类或方法,但是如果您不出于此目的而使用它,则可以将其用于任何其他字符串描述.

Another option is to use [TestOf]. While it's aimed at specifying the class or method that you are testing, you can use it for any other string description if you don't make use of it for that purpose.

最后,您可以轻松创建自己的属性属性.例如:

Finally, you can trivially create your own property attribute. For example:

c# public class JiraTicketAttribute : PropertyAttribute { public JiraTicketAttribute(string ticket) : base(ticket) { } }

c# public class JiraTicketAttribute : PropertyAttribute { public JiraTicketAttribute(string ticket) : base(ticket) { } }

使用它的测试最终将带有一个名为"JiraTicket"的属性,该属性具有您指定为参数的值.

The test on which it is used will end up with a property named "JiraTicket" with the value you specify as an argument.

这篇关于Nunit标头中的Jira票证参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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