0
我想获得单元测试项目/解决方案中所有测试方法的列表。我正在使用MSTest框架。我想获得所有测试方法的列表,以便我可以编写一些逻辑来实现所有可用测试的日志记录Vs执行什么以及哪一个正在执行等等,MSTest封装/解决方案中的所有测试方法
我是一个1岁的新手,领域。所以请提供详细的说明或代码。
我想获得单元测试项目/解决方案中所有测试方法的列表。我正在使用MSTest框架。我想获得所有测试方法的列表,以便我可以编写一些逻辑来实现所有可用测试的日志记录Vs执行什么以及哪一个正在执行等等,MSTest封装/解决方案中的所有测试方法
我是一个1岁的新手,领域。所以请提供详细的说明或代码。
我发现了一篇关于如何在Nunit中完成此任务的文章,并能够在MSTest中找到它。
var tests = new List();
var testTypes = from t in assembly.GetTypes()
orderby t.Name
select t;
foreach (var type in testTypes)
{
var testMethods = from m in type.GetMethods()
let attributes = m.GetCustomAttributes(typeof(TestMethodAttribute), true)
where attributes != null && attributes.Length > 0
orderby m.Name
select m;
foreach (var method in testMethods)
{
tests.Add(method.Name);
}
}