How can I run all NUnit Tests in Team City? - continuous-integration

We are using TeamCity 6.0 to build VS C# solutions each commit.
Once the build is complete, a different test TC project runs. So that developers can add/remove/edit VS unit test projects, how can I make TeamCity use the the sln file or search for test dll's?
I don't want to have to edit the build each time a new test project is added to the VS solution.
Run tests from: **\*Test*.dll Doesn't appear to work, it only get s the first Test (which is currently failing)

Fixed :) -
RTFL (Read the log!)
Run tests from: **\bin\debug\*Test*.dll

Related

How to run unit tests in TFS (using vNext)

I have the following project in my Visual Studio 2015 solution. I want to execute jasmine tests as part of our TFS CI build. I can run my tests successfully when I open the SpecRunner.html file although I'm failing to get them to run as part of the TFS build. I've included a screen shot of my TFS build step definition. The build is successful but the tests are not executed.
Please advise, any help greatly appreciated.
Many thanks,
Project and file locations
TFS build step
First make sure your environment on the build sever is set correct. You could manually run the test on the build server.
To use a NuGet package for the Chutzpah test runner , then you can avoid having to manually unpack the VSIX and get it into source control to deploy it to the build host.
About the detail step and build definition you could take a look at this tutorial: nUnit and Jasmine.JS unit tests in TFS/VSO vNext build

Run unit tests after build in Xamarin

I have a C# project in Xamarin for which I've written a few NUnit unit tests. To alert me to regressions as soon as possible I'd like to have Xamarin run my unit tests after every build. I'm not using CI or a build server, everything is local to my dev machine. Is there a way to modify the build task to run my tests after each compilation?
You can write a simple build script in which you invoke nunit-console.exe after your msbuild of your respective Xamarin projects.
Otherwise, I would personally recommend using Cake Build as it's fairly simple to get up and running and provides NUnit runners:
https://github.com/cake-build/cake (http://cakebuild.net/)
https://github.com/Redth/Cake.Xamarin (Xamarin Addin)
Both of these solutions should work fine locally.
Taking elements from #JonDouglas' suggestion I ended up finding the Custom Commands section and making an After Build with nunit-console ${TargetFile}. It's in the Options dialog here:

Using XUnit with Visual Studio Online

I've setup my build as below using the build definition. I'm using XUnit and locally my tests are discovered and run. I've tested the glob **\*spec*.dll and it finds all my test dlls and the build log shows that those dlls are in fact built.
However in the build log I get
Run VS Test Runner
No test found. Make sure that installed test
discoverers & executors, platform & framework
version settings are appropriate and try again.
Which seems to suggest it is trying to use the MSTest test runner instead of the XUnit test runner. How do I tell the build for visual studio online to use the XUnit test runner and discoverer?
This might be out of date now, but this is how I have it setup and working - downvote and let me know if it's wrong and I'll delete this. I got it from a blog post/MSDN page, but I can't locate it any more.
First you need to create a TFVC Team Project (doesn't matter if you don't use it again).
Into $/MyTFVC/BuildProcessTemplate/CustomActivities/
Checking the following files from xunit.net:
Now in VS, click the BUILD, Manage Build Controllers... option. Select the "Hosted Build Controller (Hosted)" and click "Properties...".
Enter the path where you checked in the DLL's into the "Version control path to custom assemblies" field:
You should be good to go.

How to Run the Unit Test As the part of Build (Not continuous integration)

I have Nunit unit test which i need to run as the part of my MS build.. I know that running all the test will slow up the build So, i need to run only the impacted test is there any way to find that out..
AFAIK running only impacted tests is not possible yet for NUnit tests. But this is possible for MSTests in Visual Studio 2010 Ultimate/Test Professional:
Recommending Tests to Run That are Affected by Code Changes
You can use Visual Studio Ultimate or Visual Studio Test Professional
2010 to help you determine which tests might have to be run, based on
coding changes that were made to the application you are testing. To
be able to use this functionality, you have to use Team Foundation
Build to build your application and use Microsoft Visual Studio 2010
for version control for your source code
Anyway you can use MSBuild Community NUnit Task to run tests from a set of the assemblies. You can do this as dependency target of standard AfterBuild target by specifying DependsOnTargets attribute.
<NUnit Assemblies="..."
IncludeCategory="..."
ExcludeCategory="..."
ToolPath="$(NUnitDllsPath)"
ProjectConfiguration="$(Configuration)"
OutputXmlFile="$(NUnitOutputPath)\UnitTests.xml"
ContinueOnError="true">
To know the impacted tests you need to track the test case code coverage. Only this way you can examine what test is impacted by the changes you are checking in. I don't know of any tool that does what you want besides Microsofts Team Foundation Server.
Running your tests as a part of the build can be done trough the Build Events properties of your project. You can execute the command line tool for NUnit.
But as PVitt already pointed out, I don't know if NUnit can work with Test Impact analysis.

Running Unit Test Projects on TFS 2010. Team Build 2010 Is Not Compiling Test DLLs

I have set up a TFS 2010 Team Build Configuration to run continuous builds.
I currently have 2 Test Projects that run inside Visual Studio 2010 IDE with no problems.
When I queue the solution (with the test projects) to build, the build log reports:
"No Test Results".
My Build Process parameters Automated Test Rule matches my test assembly names:
Run tests in assemblies matching **\*_Test.dll.
After inspecting the Build folder C:/Builds/2/[ProjectName]/[BuildName]/Binaries, I noticed that there were no .dll/.pdb files for my test projects built; even though all other project required dlls are in here.
The Test Project folders do exist in C:/Builds/2/[ProjectName/[BuildName]/Sources.
My Build Process parameters referenced under "Items to Build" => "Configurations to Build" :
Any CPU|Relase
Under Configuration Manager for my soltuion, for Any CPU and Release, I Do have my Test Projects checked off under the Build column.
From all of the documentation I have read, my tests should be running, but from the above inspection it appears that they are not even building.
Any insight or ideas into getting these unit test projects to compile and run on my TFS 2010 Build Server would be greatly appreciated.
Thanks!
When setting up the build, you can point to the vsmdi file instead of putting in the wildcard. Does that yield the same result?

Resources