解决方案同时包含 NUnit 2 和 NUnit 3 测试,我在 TFS Build 中得到 UnsupportedFrameworkException

Solution contains both NUnit 2 and NUnit 3 tests, I get UnsupportedFrameworkException in the TFS Build

在我的解决方案中有几个项目,一些使用 NUnit 2,一些使用 NUnit 3。

他们通过 NuGet 安装了相关的测试适配器和版本。

当我的 TFS 构建运行时,出现错误:

Error: Exception NUnit.Core.UnsupportedFrameworkException, Exception thrown executing tests in E:\BuildAgents\Agent1_work\s\Kittens_Local\Kitten\kitten\kitten\Kitten.Fluffy.Tests\bin\Debug\Kitten.Fluffy.Tests.dll

此项目使用的是版本 3,而其他测试使用的是版本 2。

是否可以在 TFS 中同时工作?

这似乎是 Nunit2 适配器 (Nunit TestAdapter Nuget Package) 中的一个问题。所以你不能让两者在 TFS 中同时工作。更多细节请参考Charlie在这个问题中的回答:

If you have both adapters installed, each one will run the tests for which they are designed. Each of them will display a message in for any assembly that they do not support. The message isn't meant to be an error and we try to word it in such a way that it won't be taken as such. However, we felt we have to give it just in case you expected the assembly to be handled by that particular adapter. Passing it by silently seems wrong.

When running under the VS IDE, the message does not cause a failure in the test run. It appears that running under TFS does cause a failure. If memory serves, we fixed this problem for the NUnit 3 adapter but not (yet) for the NUnit 2 adapter.