我有2.5.8和VS2010
我想针对dll运行测试,如果我输入
nunit-console a.dll
我也有这些套房
public class AllTests
{
[Suite]
public static IEnumerable Suite
{
get
{
List<Type> suite = new List<Type>();
foreach (Type testCase in UnitTests.Suite)
{
suite.Add(testCase);
}
return suite;
}
}
}
和
public class UnitTests
{
[Suite]
public static IEnumerable Suite
{
get
{
List<Type> suite = new List<Type>();
suite.Add(typeof(LicenceManagerTests));
suite.Add(typeof(CertManagerTests));
return suite;
}
}
}
如果我想使用套件运行测试,请输入
nunit-console a.dll /fixture=AllTests.Suite
但它失败并显示消息
无法找到夹具AllTests.Suite
如果你想知道我为什么使用套房,我不知道。我们在我们的项目中使用MSBuild,这是我想要的MSBuild的要求。
任何帮助表示赞赏。问候。
答案 0 :(得分:1)
使用以下标记在您的课程之前 [的TestFixture]
我认为这是缺少的,
虽然我没有使用过套房。但我正常的单元测试类似于这样的
[TestFixture]
public class A
{
//Properties
[Setup]
public void Setup()
{
//Setup code before each test, usually to set any constants, properties defined above
}
[Test]
public void TestA()
{
//test code
Asset.IsTrue(<func()>);
}
}
并以nunit-console nunit.tests.dll运行测试[无论生成的dll是什么]
告诉我是否有帮助
答案 1 :(得分:0)
我找到了解决方案。
诀窍是命名空间。 所有测试和单元测试类的命名空间应该是
"Suites".
否则我会继续接受“无法找到”.. 此致