我有许多方法具有不同的“优先级”属性,例如:
[TestMethod]
[Priority(2)]
public void TestCase1()
{
}
[TestMethod]
[Priority(1)]
public void TestCase2()
{
}
我能够得到所有这些,但我不知道如何显示他们的优先级值
var assembly = Assembly.LoadFile(@"a.dll");
var testClasses = assembly.GetTypes().Where(c => c.GetCustomAttribute<TestClassAttribute>() != null);
foreach (var testClass in testClasses)
{
using (var file = new System.IO.StreamWriter(@"C:\TestsList.txt", true))
{
file.WriteLine(testClass);
}
var testMethods = testClass.GetMethods().Where(m => m.GetCustomAttribute<TestMethodAttribute>() != null);
foreach (var testMethod in testMethods)
{
using (var file = new System.IO.StreamWriter(@"C:\TestsList.txt", true))
{
file.WriteLine(testMethod);
}
}
}
是否可以执行类似
的操作testMethod.getPriority()