【发布时间】:2015-03-26 16:31:36
【问题描述】:
我的项目中有几个程序集,每个程序集都有一个覆盖它的测试程序集(这不能改变,所以不建议)
我有一套通用测试,我希望将其包含在每个测试程序集的测试套件中。
我已经将这些常见的测试放在他们自己的程序集中,并从每个具体的测试程序集中引用了它,但是 NUnit/ReSharper 测试运行器不会选择这些测试。
如何让 NUnit 和 ReSharper 测试运行器包含/查找每个测试程序集的这些常见测试并执行它们?
更新:目前我的通用测试和每个项目测试都简单地使用 [TestFixture] 和 [Test] 属性定义
示例
来自通用程序集的示例测试
namespace Example.Common {
[Test]
public void CommonTest() {
// something that applys to all assemblies, like code analysis, obviously this is a silly example, but the contents of the test is not important. I just want this included with the other tests in the specific assemblies
Assert.AreEqual(10, Assembly.GetExecutingAssembly().DefinedTypes.Count());
}
}
来自项目特定程序集的示例测试:
namespace Example.Specific {
[Test]
public void SpecificTest() {
// something specific to this assembly
Assert.AreEqual("Example.Specific", Assembly.GetExecutingAssembly().GetName().Name);
}
}
我希望将通用测试包含在
【问题讨论】:
-
如果你能给出一个简短但完整的例子来说明你正在做什么,那么帮助会容易得多。 (例如,您使用的是
SuiteAttribute吗?) -
@jonSkeet 我不是,虽然这似乎需要手动注册,而我宁愿避免。我意识到我可以反思,然后从套件继承,但这一切似乎都相当老套,我想我一定是错过了一些技巧
-
好吧,当我们看不到您要做什么时,很难说您缺少什么。如果我们可以自己复制它,我们可以帮助您...