Question

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:

Test Explorer image showing 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:

Diagnostics output of VSO

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.":

No tests found. Diagnostics

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":

Source pull log wrt custom binaries

Additional information:

  • I am using a "default" build definition. "Default" in the sense that I only changed it with regard to the build script used (though that doesn't make a blind bit of difference).
  • I am using the TfvcTemplate.12.xaml build script.
  • The build script has **\*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.

Question

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?

Was it helpful?

Solution

Victory was achieved by

  • adding the NuGet "NUnit Test adapter for VS2012 and VS2013" package to the project containing the unit tests

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top