16

I have a VSO (f.k.a TFS) Git project that builds and deploys properly but can't find the unit tests in the solution.

This is the message I see...

No test found. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again.

In my build definition I specify

 - Run tests in test sources matching **\Test*.dll, Target platform: 'X86'

My solution structure is like this

/Tests.Unit.ProjectName/Tests.Unit.ProjectName.csproj
/ProjectName/ProjectName.csproj
jessehouwing
  • 106,458
  • 22
  • 256
  • 341
devfunkd
  • 3,164
  • 12
  • 45
  • 73

2 Answers2

22

Another option is to install the NUnit Test Adapter for VS2012 and VS2013 NuGet package in the unit test project. The build server will find it there. No other changes needed.

klings
  • 963
  • 6
  • 12
  • Worked perfectly for me - this should be the accepted answer. – Paul Stovell Jul 31 '14 at 07:11
  • This new feature of Team Build is great! – jessehouwing Aug 27 '14 at 11:37
  • Exactly what I was looking for. Worked great. Thanks. – gmetzker Sep 24 '14 at 21:41
  • 1
    Passersby using Visual Studio Online build definitions, in the Visual Studio Test build step: **1.** Note that you may also need to use the "*Test Assembly*" field to properly match your test dlls. **2.** You may also need to provide the "*Path to Custom Test Adapters*", "`$(Build.SourcesDirectory)\packages`" if you're using NuGet. See [here](https://nocture.dk/2015/06/19/xunit-or-nunit-with-visual-studio-online-build/) for details. – kdbanman Sep 15 '15 at 22:08
7

To run NUnit tests, the build system needs to be told where it can find the 3rd party test runner assemblies. Currently it can't load those from a Git Repository. But... It can load them from a Team Foundation Source Control folder in another Team Project. So simply create an empty project using the standard source control and reference the assemblies from there.

In this doc, you're explained how to configure Team Build to load nUnit tests. The basic thing is that you need to copy the Test Runner assembles and stick them in a TFVC repository. You then need to tell the Build Controller where it can find these assemblies.

The hosted build controller can load these assemblies from any team project within your VSO account, so just create a second project which can store these.

See also:

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
  • I thought VS2012 and newer come with vstests.console.exe which can run most common test frameworks including NUnit. http://blogs.msdn.com/b/bhuvaneshwari/archive/2012/06/16/vstest-console-exe-commandline-test-runner.aspx Will vstest not work? – devfunkd Nov 17 '13 at 07:32
  • 2
    It will work, but for vstest to detect nUnit, you need to provide the test adapter for it: http://visualstudiogallery.msdn.microsoft.com/6ab922d0-21c0-4f06-ab5f-4ecd1fe7175d. In the box it ships the Mstest adapter only. You can add NUnit, XUnit.NET or any other by dropping the adapter binary into the binaries folder. – jessehouwing Nov 17 '13 at 07:45