问题
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?
回答1:
Many folks use the [Description]
attribute for this purpose.
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) { }
}
The test on which it is used will end up with a property named "JiraTicket" with the value you specify as an argument.
来源:https://stackoverflow.com/questions/52645207/jira-ticket-reference-in-nunit-header