简体   繁体   中英

NUnit3 tests don't run on TFS build

we are currently migrating our unit tests from using MSTest to NUnit (version 3.2.1) but are having problems running the NUnit tests from our TFS .xaml build definition. The TFS build definition is using the rule "Run tests in assemblies matching **\\*.test*.dll". For my NUnit test project I have downloaded, installed and referenced the following NuGet packages:

1) NUnit v3.2.1

2) NUnit3TestAdapter v3.0.10

Executing my tests within VS (test explorer) works perfectly, and I thought that these steps would be enough to ensure they were also run as part of the CI build on TFS, however the tests are never executed. I have no error/warning/message pertaining to these tests in the diagnostic output, however I do see that the build process has detected my assembly as a candidate for unit tests seeing as it matches the aforementioned wildcard rule (**\\*.test*.dll).

I also tried putting the NUnit3TestAdapter assemblies in the "Version control path to custom assemblies" folder defined in the build controller properties for TFS but to no avail.

Can anyone see if I am missing a step in the process here. From all that I have read on these forums I seem to have done everything necessary but they still don't execute.

I simplified the problem greatly by just running MSTest,exe (which is what TFS build uses) directly on the assembly containing my NUnit tests. The assembly in question has both the adapter and nunit frameworks installed as NuGet packages, and still MsTest reports that no tests are found (see below):

C:\\Users\\hdav>"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\MSTest.exe" /testcontainer:e:\\MyCode\\nunit\\ExpectedExceptionExample\\bin\\Debug\\ExpectedExceptionExample.dll

Loading e:\\MyCode\\nunit\\ExpectedExceptionExample\\bin\\Debug\\ExpectedExceptionExample.dll...

Starting execution...

No tests to execute.

I was experiencing the same problem and found that pbd files for the test projects need to be present in order for the adapter to discover tests.

Whilst .pbd files were being generated locally, the build (in this case TF Build) was supplying the /p:DebugType=None switch to the MSBuild arguments. Removing the switch allowed the tests to be discovered and run in the build. Could you have something similar in your build definition?

The issue has been accepted as a bug on GitHub.

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