2
votes

I am relatively new working with .NET and Visual Studio. I have a project that has NUnit tests. I am using Visual Studio 2015. Test Adapter is managed through Nuget Package manager and the version used is 3.10.1. The package.config file looks like below:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Autofac" version="3.5.0" targetFramework="net451" />
  <package id="AutoMapper" version="4.2.1" targetFramework="net451" />
  <package id="DelegateDecompiler" version="0.18.0" targetFramework="net451" />
  <package id="DelegateDecompiler.EntityFramework" version="0.18.0" targetFramework="net451" />
  <package id="EntityFramework" version="6.1.3" targetFramework="net451" />
  <package id="GenericLibsBase" version="1.0.1" targetFramework="net451" />
  <package id="GenericServices" version="1.0.9" targetFramework="net451" />
  <package id="log4net" version="2.0.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.SignalR.Core" version="2.0.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net451" />
  <package id="Microsoft.Owin" version="2.1.0" targetFramework="net451" />
  <package id="Microsoft.Owin.Security" version="2.1.0" targetFramework="net451" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net451" />
  <package id="Mono.Reflection" version="1.0.0.0" targetFramework="net451" />
  <package id="Moq" version="4.2.1408.0717" targetFramework="net451" />
  <package id="Newtonsoft.Json" version="6.0.4" targetFramework="net451" />
  <package id="NUnit" version="3.10.1" targetFramework="net451" />
  <package id="Owin" version="1.0" targetFramework="net451" />
</packages>

Also the .csproj file includes the reference as below:

<Reference Include="nunit.framework, Version=3.10.1.0, Culture=neutral, PublicKeyToken=xxxxxxxx, processorArchitecture=MSIL">

<HintPath>..\packages\NUnit.3.10.1\lib\net45\nunit.framework.dll</HintPath>
      <Private>True</Private>
    </Reference>

When the test is run locally, all the tests are executed successfully.

------ Run test started ------
NUnit Adapter 3.10.0.21: Test execution started
Running all tests in <path to release>\Tests.dll
NUnit3TestExecutor converted 54 of 54 NUnit test cases
NUnit Adapter 3.10.0.21: Test execution complete
========== Run test finished: 54 run (0:00:14.202451) ==========

The next ask is to try configuring the same in the Hosted VS 2017 environment in Visual Studio Team Services (VSTS) and build the project using available build templates. The build includes the following steps:

  1. NuGet Tool Installer
  2. NuGet restore
  3. Build Solution
  4. Execute VSTest
  5. Publish artifact

While I trigger the build, the build fails in Step 4.

2018-03-29T13:18:57.8600581Z vstest.console.exe 
2018-03-29T13:18:57.8600783Z "<release path>\Tests.dll"
2018-03-29T13:18:57.8600996Z /EnableCodeCoverage
2018-03-29T13:18:57.8601174Z /logger:"trx"
2018-03-29T13:18:57.8949472Z Starting test execution, please wait...
2018-03-29T13:18:57.9616355Z Warning: Using Isolation mode to run the tests as diagnostic data adapters were enabled in the runsettings. Use the /inIsolation parameter to suppress this warning.
2018-03-29T13:19:13.6376907Z Warning: No test is available in <path to release>\Tests.dll. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again.
2018-03-29T13:19:13.6377691Z 
2018-03-29T13:19:13.8424412Z 
2018-03-29T13:19:13.8425192Z Attachments:
2018-03-29T13:19:13.8425592Z   <path>\buildguest_FACTORYVM-AZ49 2018-03-29 13_19_05.coverage
2018-03-29T13:19:13.8425875Z 
2018-03-29T13:19:13.8972522Z Information: Additionally, you can try specifying '/UseVsixExtensions' command if the test discoverer & executor is installed on the machine as vsix extensions and your installation supports vsix extensions. Example: vstest.console.exe myTests.dll /UseVsixExtensions:true
2018-03-29T13:19:13.9197235Z 
2018-03-29T13:19:14.3324288Z ##[warning]No results found to publish.
2018-03-29T13:19:14.4972081Z ##[section]Finishing: Test - testAssemblies

Is there any additional configuration required that is missed?

2

2 Answers

1
votes

It looks like you have the NUnit 3 Test Adapter installed as a Visual Studio extension locally. That will ensure that any project with NUnit tests can automatically be discovered and executed by Visual Studio.

But that extension is not installed on the build server, and you probably want to keep it that way.

Instead of installing the extension on each and every build server and keeping it up to date, it's a better solution to add the test adapter to your project as a nuget package, that way it will be available on the build server without further configuration.

https://www.nuget.org/packages/NUnit3TestAdapter/

0
votes

I have also encountered the same issue.

Steps to resolve this issue -

 1. Install/Reinstall NUnit3TestAdapter package
 2. Delete Debug folder from the Bin
 3. Clean --> Build the project

Note - Also ensure all the packages are installed properly.

Now try to execute the tests.