NUnit - 无法在程序集中找到测试 [英] NUnit - Unable to find test in assembly
本文介绍了NUnit - 无法在程序集中找到测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 Visual Studio 2010 中向类库添加了一个测试.但是,当我尝试在 NUnit 中加载程序集时,出现以下错误:
I have added a test to a class library in Visual Studio 2010. However when I try to load the assembly in NUnit I get the following error:
测试加载失败!
System.ApplicationException:无法在程序集中找到测试.
System.ApplicationException: Unable to find test in assembly.
可能有什么问题?测试有以下简单代码:
What could be wrong? The test has the following simple code:
using NUnit.Framework;
namespace Web.Tests
{
[TestFixture]
public class Test
{
[Test]
public void ShouldLoadController()
{
Assert.AreEqual(1,1);
Assert.IsTrue(true);
}
}
}
推荐答案
答案好像是注释掉 Nunit 配置文件中对 2.0 的引用:
The answer seems to be to comment out the reference to 2.0 in the Nunit configuration file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<!-- Comment out the next line to force use of .NET 4.0 -->
<!--<supportedRuntime version="v2.0.50727" />-->
<supportedRuntime version="v4.0.30319" />
</startup>
</configuration>
我不确定为什么这是必要的,因为它似乎应该能够选择正确的运行时间.
I'm not sure why this is necessary, as it appears that it should be able to select the correct run time.
这篇关于NUnit - 无法在程序集中找到测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文