What else is needed to get the Hosted Build Controller to run my NUnit tests

耗尽温柔 提交于 2019-12-11 03:04:09

问题


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:

  • 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?


回答1:


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.



来源:https://stackoverflow.com/questions/22461317/what-else-is-needed-to-get-the-hosted-build-controller-to-run-my-nunit-tests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!