问题
I'm building and deploying a solution from Visual Studio 2015 using TFS 2012 without issues. I have decided to incorporate my unit tests as part of the prerequisites for the build process.
Independent of the msbuild process, the unit tests run without issue and succeed; however, when I incorporate them as part of my build process I am getting the following exception in my build:
Exception NUnit.Core.UnsupportedFrameworkException, Exception thrown executing tests in D:\Builds\4\PA1111CE\Dev1111dBus\bin\mmmTests.dll
No test is available in D:\Builds\4\PA1111CE\Dev1111dBus\bin\mmmTests.dll. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again.
The build partially succeeds.
In order to make sure that tests are run, I've set the Disable Tests property within Process to false:
In addition to this I've set options for Automated Tests:
The only test runners which are available are as follows:
also, per my extensions and updates, it is showing that I indeed DO have nunit adapter 3 installed:
What am I doing wrong? Why does my build only partially succeed?
回答1:
I had the same problem on my build server when using NUnit 3 via NuGet. I uninstalled NUnit 2 and 3 test adapters from Visual Studio, and NUnit 2 from the machine. I still had the problem.
In my case the issue was caused by 4 NUnit2 DLLs hiding in :
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Extensions
As soon as they were deleted the TFS build executed perfectly.
回答2:
The message indicates that you are trying to run NUnit tests using the wrong Visual Studio adapter. Use the 2.0 adapter for NUnit 2.x tests and the 3.0 adapter for NUnit 3.0 tests.
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.
回答3:
I had the same exact issue. I use NUnit 3.2.1, and had NUnit test adapters 2.0 and 3.0 installed.
I couldn't figure out how to switch adapters, so I disabled the 2.0 one. Now I get no errors (even though it was only a message like you - test passed/failed as they should have).
To disable 2.0 test adapter (also maybe install 3.0): Tools -> Extensions and Updates -> Search or locate Nunit 2.0 and click disable or uninstall.
回答4:
Found this article, but I have not tested it myself: NUnit failed to load in TFS build
I ended up temporarily excluding my unittest-project from the build like described here
来源:https://stackoverflow.com/questions/35191374/nunit-tests-throwing-exception-only-when-run-as-part-of-tfs-msbuild-process