Reputation: 115
I'm reading a tests collection from some data source. so I get a collection of objects including: testAssembly,testClass,testName and groupID per object. I'm trying to find a way for each testName create Testcategory attribute and give him the groupID. evrey test can be in a different assemblly,solution or class Thanks
example: before:
[TestMethod]
public void Test_test()
{
code....
}
after:
[TestCategory(groupID)]
[TestMethod]
public void Test_test()
{
code....
}
Upvotes: 3
Views: 1148
Reputation: 205
You can write your custom attribute. There is a lot of material for this online.
Example (from link):
[System.AttributeUsage(System.AttributeTargets.Class |
System.AttributeTargets.Struct)
]
public class AuthorAttribute : System.Attribute
{
private string name;
public double version;
public AuthorAttribute(string name)
{
this.name = name;
version = 1.0;
}
}
Usage:
[Author("P. Ackerman", version = 1.1)]
class SampleClass
{
// P. Ackerman's code goes here...
}
Upvotes: 3