NUnit 加载失败,使用版本 3.11

tre*_*ndy 5 nunit unit-testing visual-studio nuget nunit-3.0

当我降低到 3.10 时,它可以工作,但不知道为什么它最近停止了。我尝试的一切都不起作用。

这就是输出中显示的内容。我尝试了网上找到的许多选项,但似乎没有任何帮助:

[13/03/2019 17:10:44 Informational] ------ Run test started ------
[13/03/2019 17:10:45 Informational] NUnit Adapter 3.13.0.0: Test execution started
[13/03/2019 17:10:45 Informational] Running all tests in E:\xxx\xxx\xxx.Tests\bin\Debug\xxx.Tests.dll
[13/03/2019 17:10:45 Informational]    NUnit failed to load E:\xxx\xxx\xxx.xxx\bin\Debug\xxx.Tests.dll
[13/03/2019 17:10:45 Informational] NUnit Adapter 3.13.0.0: Test execution complete
[13/03/2019 17:10:45 Warning] No test matches the given testcase filter `FullyQualifiedName=xxx.xxx.xxxTestss.xxxxnameshouldbesomething` in E:\xxx\xxx\xxx.Tests\bin\Debug\xxx.Tests.dll
[13/03/2019 17:10:45 Informational] ========== Run test finished: 0 run (0:00:01.6716706) ==========
Run Code Online (Sandbox Code Playgroud)

我也创建了一个基本测试来确认,在这里:

Imports NUnit.Framework
Imports Should

<TestFixture()>
Public Class UnitTest1

    <Test()> Public Sub TestMethod1()
        Dim b As Boolean = False
        b.ShouldBeFalse
    End Sub

End Class
Run Code Online (Sandbox Code Playgroud)

我尝试删除 TestFixture,将其重命名为 TestClass(但我需要使用 NUnit!)

太奇怪了...我在解决方案中有一个项目确实有效,但我找不到任何区别,这并没有帮助。

我什至尝试创建一个新的空项目...但这甚至不适用于任何版本的 NUnit(但我想我会将其作为一个单独的问题提出)。

tre*_*ndy 6

发现问题,由于某种原因,我的项目的 Microsoft.VisualStudio.QualityTools.UnitTestFramework 标志“Copy Local”被设置为 false。

当我将其更改为 true 时,我的测试现在正在被拾取并运行:)

3.10版本似乎不需要这个,这就是为什么当降低版本时,它又开始工作了。

(我不认为设置这个标志会影响本地运行)

  • @akarnokd 抱歉,刚刚看到这个...当您单击解决方案资源管理器中的引用时,在“属性”底部,您应该看到这个标志 (2认同)