How to run NUnit test in Visual Studio Team Services - continuous-integration

When I try to execute NUnit test in VSTS task I am getting the following error:
Warning: The path 'C:\a\1\s\INCASOL.IP\packages' specified in the 'TestAdapterPath' does not contain any test adapters, provide a valid path and try again.
I have these tasks in VSTS:
The "Run unit test" task is configured as follows:
Note I have set the "Path to Custom Test Adapters".
I think the dlls for NUnit are properly copied to packages folder because in "Nuget restore" task I can see the following:
Added package 'NUnit.2.6.4' to folder 'C:\a\1\s\INCASOL.IP\packages'
Notes: The NUnit version is 2.6.4 and I'm using Hosted Agent

After a few hours looking for a solution, I solved it few minutes after having asked my question.
Although I could run my test in my local machine using NUnit Test Adapter, this package hadn't been added to my packages folder. So, once I run
Install-Package NUnitTestAdapter
for my test projects, everything works fine.

Related

MSB4019 VSTO targets not found TeamCity build agent

I'm using a TeamCity build server to try and build an Outlook Addin, I can build & test the code using TeamCity, but when it comes to publishing the app to a folder I get the following error.
Obviously the build server is missing some SDK components to complete the package\publish step.
Does anyone know which Windows SDK I need to get installed on the build server?
Nothing to do. None of the projects specified contain packages to restore.
XXXXXXXX.Outlook.csproj(331,3): error MSB4019:
The imported project "C:\Program Files\dotnet\sdk\7.0.102\Microsoft\VisualStudio\v17.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets" was not found.
Confirm that the expression in the Import declaration "C:\Program Files\dotnet\sdk\7.0.102\Microsoft\VisualStudio\v17.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets" is correct, and that the file exists on disk.
Build FAILED.

NUnit3 multiple App.config files in Teamcity

I'm having a strange problem. I have a bunch of integration tests projects. Each test project has a configuration file (app.config).
Currently, in my "Run Integration Tests" build step, the NUnit3 console runner allows me to specify only one config file (where it says "Path to application configuration file"). I have specified the path to one of my integration test app.configs. The problem is, the tests in other test projects fail because the Nunit3 console doesn't recognize their app.config files.
How can I have TeamCity run each test project with its own app.config file in its bin/release folder?
FYI: This is what I have specified in the NUnit assembly lookup: **\bin\Release\*.Integration.Tests.dll
Turns out, this was my problem. After removing all references between my test projects, I noticed that the build time was reduced by 50%.

Chutzpah - is it possible to integrate chutzapah test running with visual studio build

Is it possible to integrate chutzapah test running with visual studio build?
What I mean here is - if any test fails the build fails.. .that way..
I think you have 2 ways of doing this:
install the Chutzpah test adapter on each build machine and get the running the tests in test explorer.
Then customize your msbuild scripts to run the tests.
Use the command line + custom msbuild task
It looks like Chutzpah has a command-line runner, so you can create a PowerShell script which gets called from your build server to run the tests. See the Chutzpah documentation for more information, but it should be chutzpah.console.exe under: Chutzpah.3.2.4\tools
Next if you want to integrate with Visual Studio build it means msbuild integration. Take a look at the exec task on how to run custom commands and react based on the results

TeamCity - Configure MSTest Settings to execute a command before the tests

I try to configure the MSTest Settings ssection [Step 3 Runner: Visual Studio (sln)]. My particular configuration require to call a set of scripts (TestSetup.cmd) before the tests. Everything works fine in Visual Studio, but I don't know how to call the scripts from TeamCity.
I tried to add in the MSTest metadata the .vsmdi file but without success. The script are not executed.
My question is how to call the command from TeamCity in the MSTest Settings section?
Thank you and best regards!
testrunconfig file:
This is a default test run configuration for a local test run.
MSTest Settings screen shot TestSetup.cmd
Versions :
TeamCity Enterprise 5.1.3
Microsoft Visual Studio Team System 2008 Development Edition
I
Add a build step before the MSTest runner which runs your testsetup.cmd.

How do I configure visual studio to run xUnit.net tests?

I have configured Visual Studio 2010 to debug xUnit.net tests by setting the Project Settings | Debug | Start External Program to run the xUnit.net console runner.
This works OK but only when providing the complete path to the test project dll via the Command Line Arguments eg: "c:\development\TestProject.dll"
I have tried using $(BinDir)$(TargetName)$(TargetExt) as parameters via the Command Line Arguements section but it does not work. Any suggests on how I can avoid the explicit/full path?
This is what I use in my .csproj file to run the xUnit GUI runner as the start action:
<PropertyGroup>
<StartAction>Program</StartAction>
<StartProgram>$(MSBuildProjectDirectory)\..\..\Packages\xunit.runners.1.9.1\tools\xunit.gui.clr4.exe</StartProgram>
<StartArguments>"$(MSBuildProjectDirectory)\$(OutPutPath)$(AssemblyName).dll"</StartArguments>
</PropertyGroup>
For this to work, all you have to do is install the xUnit.net Runners NuGet package:
PM> Install-Package xunit.runners
The only downside so far, is that it's version specific, so every time you update the NuGet package to latest, you should update this configuration to point to the correct runner.
This answer was given before James' and Brad's awesome work with xUnit.net Runners. See michielvoo's answer below.
To avoid the problem of explicitly giving the library name one can use cmd.exe with command line arguements: /C xunit.console.exe $(BinDir)$(TargetName)$(TargetExt)
Check Use Output Window
Use the Tools|Options|Keyboard configuration to assign a hot key.
A alternative route is use a VS plugin as testrunner. For instance ReSharper.
I simply type the full name of the assembly thats all.
Under command line arguments: SharedDataBridge.Tests.dll

Resources