简体   繁体   中英

The test couldn't be found in the assembly

I was trying to execute a sample PNunit tests, but it is failing with the following error

The test xxx couldn't be found in the assembly xxx.dll

I have followed the Pnunit doc, but it is not helpful.

项目参考

Here is the test case

using NUnit.Framework;

namespace TestLibraries
{
    [TestFixture]
    public class PuniTest
    {
        [Test]
        public void EqualTo19()
        {
            Assert.AreEqual(19, (15 + 4));
        }
    }
}

and the test.conf file

<TestGroup>
  <Variables>
    <Variable name="$agent_host" value="localhost" />
  </Variables>

  <ParallelTests>
      <ParallelTest>
        <Name>Testing</Name>
        <Tests>
          <TestConf>
            <Name>Testing</Name>
            <Assembly>pnunit35.dll</Assembly>
            <TestToRun>TestLibraries.PuniTest.EqualTo19</TestToRun>
            <Machine>$agent_host:8080</Machine>
          </TestConf>
        </Tests>
      </ParallelTest>
    </ParallelTests>

</TestGroup>

I have compiled the code, copied the "pnunit35.dll" and "test.conf" files to " NUnit.Runners.Net4.2.6.4\\tools " folder to run the tests

And run the following commands (in batch file) to start the agent and run the scripts from Nunit test runner folder

start pnunit-agent 8080 .
pnunit-launcher test.conf

On running the batch scripts, tests are failing with the following error

The test TestLibraries.PuniTest.EqualTo19 couldn't be found in the assembly pnunit35.dll

Could some body please look into this?, thanks in advance

您有可能错过了Visual Studio中的NUnit测试适配器

You may have a processor architecture mismatch. If your project is 64bit, go to test -> test settings -> default processor architecure -> x64.

Thanks Everyone,

Finally I found root cause of the problem, it is the pNunit versions which is incompatible with the NUnit-3.6.0 and Nunit.Runner-4.2.6.4 I was using in my project.

When I googled about the issue, I found that pNunit-2.6.4 is not compatible with the latest Nunit-3.6.0. So, I have changed Nunit and NUnit.Runners to 2.6.4. Then the tests worked without any issues.

Update: Use .Net Framework 3.5

Update2: [ .Net Framework 4.5 ] if you are working on .Net Framework 4 and above, start PNunit-agent in compatiblity mode.

Edit "pnunit-agent.exe.config" file in text editor and add the following code in 'configuration'

<startup>
    <supportedRuntime version="v4.0.30319" />
</startup>

Close the pnunit-agent and re-run that will solve the issue

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