简体   繁体   中英

NUnit - Unable to find test in assembly

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:

Test load failed!

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);
        }
    }
}

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM