NUnit 获取结果不是 运行
NUnit Get outcomes not run
我有一个简单的 NUnit 代码不起作用,如下所示:
[TestFixture("abc", "xyz", typeof(int))]
public class GenericTestFixture<T>
{
T tt;
string aa;
string bb;
public GenericTestFixture(string a, string b, T t)
{
tt = t;
aa = a;
bb = b;
}
[Test]
public void Test1()
{
Debug.WriteLine($"aa is {aa}, bb is {bb}, t is {typeof(T).ToString()}");
}
[TestCase(1)]
public void TestMethod(int c)
{
Assert.Equals(c, 1);
}
}
出于某种原因,在单击测试资源管理器中的 运行 按钮后,我得到了 Outcomes with 2 Not 运行 消息,然后我在构造函数中放置了一个断点并尝试调试,但它没有'按预期停止。是什么原因以及如何解决?我的 NUnit 版本是 3.12.0,NUnit3TestAdapter 版本是 3.15.1
UPDATE1
我转到输出 window 并得到以下日志消息:
[11/5/2019 8:21:40.468 PM Informational] Skipping assembly - no matching test cases found
[11/5/2019 8:21:40.743 PM Informational] NUnit Adapter 3.15.1.0: Test execution complete
[11/5/2019 8:21:40.815 PM Warning] No test matches the given testcase filter `FullyQualifiedName=DataDrivenTests.GenericTestFixture.Test1|FullyQualifiedName=DataDrivenTests.GenericTestFixture.TestMethod` in D:\code\NUnit_practice\nunit-csharp-samples\DataDrivenTests\bin\Debug\DataDriven.Tests.dll
[11/5/2019 8:21:42.752 PM Informational] ========== Run finished: 0 tests run (0:00:06.1448651) ==========
您需要遵循 NUnit Generic Test Fixtures 文档,如下所示:
[TestFixture(typeof(int), "abc", "xyz")]
public class GenericTestFixture<T>
{
private readonly string _aa;
private readonly string _bb;
public GenericTestFixture(string a, string b)
{
_aa = a;
_bb = b;
}
[Test]
public void Test1()
{
Debug.WriteLine($"aa is {_aa}, bb is {_bb}, t is {typeof(T)}");
}
[TestCase(1)]
public void TestMethod(int c)
{
Assert.AreEqual(c, 1);
}
}
调试输出:
我有一个简单的 NUnit 代码不起作用,如下所示:
[TestFixture("abc", "xyz", typeof(int))]
public class GenericTestFixture<T>
{
T tt;
string aa;
string bb;
public GenericTestFixture(string a, string b, T t)
{
tt = t;
aa = a;
bb = b;
}
[Test]
public void Test1()
{
Debug.WriteLine($"aa is {aa}, bb is {bb}, t is {typeof(T).ToString()}");
}
[TestCase(1)]
public void TestMethod(int c)
{
Assert.Equals(c, 1);
}
}
出于某种原因,在单击测试资源管理器中的 运行 按钮后,我得到了 Outcomes with 2 Not 运行 消息,然后我在构造函数中放置了一个断点并尝试调试,但它没有'按预期停止。是什么原因以及如何解决?我的 NUnit 版本是 3.12.0,NUnit3TestAdapter 版本是 3.15.1
UPDATE1
我转到输出 window 并得到以下日志消息:
[11/5/2019 8:21:40.468 PM Informational] Skipping assembly - no matching test cases found
[11/5/2019 8:21:40.743 PM Informational] NUnit Adapter 3.15.1.0: Test execution complete
[11/5/2019 8:21:40.815 PM Warning] No test matches the given testcase filter `FullyQualifiedName=DataDrivenTests.GenericTestFixture.Test1|FullyQualifiedName=DataDrivenTests.GenericTestFixture.TestMethod` in D:\code\NUnit_practice\nunit-csharp-samples\DataDrivenTests\bin\Debug\DataDriven.Tests.dll
[11/5/2019 8:21:42.752 PM Informational] ========== Run finished: 0 tests run (0:00:06.1448651) ==========
您需要遵循 NUnit Generic Test Fixtures 文档,如下所示:
[TestFixture(typeof(int), "abc", "xyz")]
public class GenericTestFixture<T>
{
private readonly string _aa;
private readonly string _bb;
public GenericTestFixture(string a, string b)
{
_aa = a;
_bb = b;
}
[Test]
public void Test1()
{
Debug.WriteLine($"aa is {_aa}, bb is {_bb}, t is {typeof(T)}");
}
[TestCase(1)]
public void TestMethod(int c)
{
Assert.AreEqual(c, 1);
}
}
调试输出: