简体   繁体   English

在装配中找不到测试

[英]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 我试图执行一个示例PNunit测试,但它失败并出现以下错误

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

I have followed the Pnunit doc, but it is not helpful. 我已经关注了Pnunit文档,但它没有帮助。

项目参考

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 和test.conf文件

<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 我编译了代码,将“pnunit35.dll”和“test.conf”文件复制到“ NUnit.Runners.Net4.2.6.4 \\ tools ”文件夹中运行测试

And run the following commands (in batch file) to start the agent and run the scripts from Nunit test runner folder 并运行以下命令(在批处理文件中)以启动代理并从Nunit test runner文件夹运行脚本

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. 如果您的项目是64位,请转到测试 - >测试设置 - >默认处理器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. 最后我找到了问题的根本原因,它是与我在项目中使用的NUnit-3.6.0和Nunit.Runner-4.2.6.4不兼容的pNunit版本。

When I googled about the issue, I found that pNunit-2.6.4 is not compatible with the latest Nunit-3.6.0. 当我搜索这个问题时,我发现pNunit-2.6.4与最新的Nunit-3.6.0不兼容。 So, I have changed Nunit and NUnit.Runners to 2.6.4. 所以,我已经将Nunit和NUnit.Runners改为2.6.4。 Then the tests worked without any issues. 然后测试没有任何问题。

Update: Use .Net Framework 3.5 更新:使用.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. Update2: [。 Net Framework 4.5 ]如果您正在使用.Net Framework 4及更高版本,请在兼容模式下启动PNunit-agent。

Edit "pnunit-agent.exe.config" file in text editor and add the following code in 'configuration' 在文本编辑器中编辑“pnunit-agent.exe.config”文件,并在“配置”中添加以下代码

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

Close the pnunit-agent and re-run that will solve the issue 关闭pnunit-agent并重新运行以解决问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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