I am unable to get Visual Studio Online's Hosted Build Controller to run my NUnit tests despite following the instructions given in "Add assemblies for custom activities and other unit test frameworks" to add the required NUnit binaries and making the build controller aware of them.
I tried all this first in a Git project and couldn't get it to work, despite the information in Visual Studio Online CI Nunit Tests not found during build.
My current efforts are in a TFVC project, so the fact that the hosted build controller is unable to pull from Git shouldn't be a factor.
The project I am using is a simple class library, no code but the code automatically added by the project wizard. The test project is similar: used the wizard to add a new test project, added the NUnit package and added a new test class referencing the NUnit framework rather than the MS one. In the IDE the test runner correctly shows two unit tests: TestMethod1
which was added by the wizard and NUnit_TestMethod1
which was added by me in the new test class. When I "Run all", both tests are run:
All seems fine and dandy. However, when I run a build on Visual Studio Online using the Hosted Build Controller, only the MS test is executed:
When I remove the reference to the MS test framework and adjust the attributes in the UnitTest1 class to the NUnit attributes, the IDE is again able to see and run both (it "rediscovered" TestMethod1 as indicated by a blue icon in the TestExplorer before running the tests), but the hosted build controller then reports "No tests found.":
The "Version control path to custom assemblies" of the build controller properties was set using the ellipses button (so Visual Studio decided what to put there) and is set to $/BJM Software TFVC/CustomBinaries
. The build's diagnostics log shows that the custom binaries are "gotten":
Additional information:
**\*test*.dll;**\*test*.appx
as the test sources spec (which is unchanged from the default).Run settings are "no run settings file" and "default type of run settings".
I tried first with "hard" references to the nunit.framework.dll as well. This compiled fine (ie the NUnit code is found by the compiler), but didn't run the tests. Switching to a NuGet package didn't help.
What am I missing? What else do I need to do to get the Hosted Build Controller of Visual Studio Online to run my NUnit tests?
Victory was achieved by
The logs now show "2 of 2 test(s) passed".
Pffff.
Adding the Test Adapter package also allowed me to remove the $/BJM Software TFVC/CustomBinaries
path from the "Version control path to custom assemblies" of the build controller properties.