![](/img/trans.png)
[英]How can I unit test views and authorization attributes of my asp.net mvc application in nUnit?
[英]Blank output for an ASP.NET NUnit test application
我目前正在使用NUnit为 ASP.NET 应用程序编写测试用例。
我创建了一个示例测试项目,并添加了 NUnit 最新版本 (3.6.1) 和 NUnitTestAdapter 2.1.1。
如果我通过单击菜单Test → Windows → Text Explorer来运行应用程序,我会在Output Window中看到一个空白屏幕。 为什么?
我的代码是:
[TestFixture]
public class SampleTest
{
[Test]
public void StringCheck()
{
string str = "Hello";
Assert.That(str, Is.EqualTo("Hello"));
}
[Test]
public void EmptyCheck()
{
string str = "siva";
Assert.That(str, Is.EqualTo(string.Empty));
}
[Test]
public void NumberCheck()
{
int i = 0;
Assert.That(i, Is.EqualTo(0));
}
}
您正在使用 NUnit 2.x 系列的适配器,而不是 NUnit 3 适配器。 NUnit 版本 2 和 3 大不相同,并且有两个单独的 Visual Studio 适配器来运行测试。
这是运行 NUnit 3.6.1 测试所需的:
我找到了解决方案。 问题出在 NUnit 版本(3.6.1)上。 现在我更新了 NUnit 2.6.4。 它对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.