How to run MSTest with custom assembly path using command-line - visual-studio

MSTest uses in CI environment to run set of unit tests. These set of unit test need custom binaries to run. I'm not sure how can pass the custom assembly path to the MSTest.exe when I run the unit test using command line for debugging purpose. When it runs via TFS there is a place to configure custom assembly path in build controller as this image.
So, how to run MSTest with custom assembly path using command-line

Related

How to specify xUnit Test Names in .runsettings file

I have a XUnit test project. I am planning to use .runsettings file and I need to specify the TEST NAMES which I have to run in .runsettings file.
I am going to run the test in commandline using "dotnet vstest" command and specifying the test dll and settings file. I am using runsettings for the first time.
My issue is I dont have idea about how to specify test names to be run in runsettings file. Can anybody please help me on this?

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%.

How to run NUnit test in Visual Studio Team Services

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.

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

How to call Nunit from Visual Studio in a batch file

I have set my Visual Studio to start Nunit as an external program to run all the tests written in a module.
Now what I am trying to do is to create a batch file which will call Myproj.exe. What I am expecting is that it will run Nunit as I have set it to run an external program and execute all my tests in nunit.exe, but when I run that batch file it starts running from Visual Studio instead of opening NUnit.
Can any one please give me a clear idea as how to accomplish it?
I am too much stuck.
Now I am trying to run the following commands in shell
nunit-x86.exe
Can you please tell how should I load my visualbasic project file (exe) here and then run all the tests from here
as unable to execute following command
nunit nunit.tests.vbproj /config:release
You can make NUnit start everytime you debug your "NUnit tests".
You can attach the debugger in Visual Studio Express doing it that way.
If you use a "full version" of VS do it that way:
Note that if you’re using the full and
not the express version of Visual
Studio 2005, you can do this by
opening up the project’s properties,
and in the Debug tab select Start
External Program: and navigate to the
NUnit executable, and set
YourCompanyname.YourProject.Test.dll as the
Command Line Arguments.
I got that ideas from this tutorial(Page 4/5) and love it.
You can also run NUnit after every successful build in Visual Studio with a Post-Build Event.
In VS2005, right-click on the project that has your tests and select Properties. Then on the Build Events tab, in the "Post-build event command line", put this* to use the console:
nunit-console /xml:$(ProjectName).xml $(TargetPath)
or this to use the GUI::
nunit $(TargetPath) /run
In "Run the post-build event:", leave the default: "On successful build"
If you use the GUI, know that your build will appear to be hung up until you close the GUI app.
*NOTE: The nunit console command line docs say "By default the nunit-console program is not added to your path."
you can just shell nunit.exe with the command line to your assembly to run tests in.
You can load nUnit.exe (nUnit-Console.exe for command line execution) using external tool features in Visual studio. Once you add the command via external tools feature (as explained in this blog), you can use it for any project to execute the tests. (Other is to add through project properties but that needs to be done for every project). Also in the arguments you can pass /include or /exclude to include or exclude categories of the tests.
The advantage of this method is you need not worry about giving path to DLL file and it works for any project you are on and gets executed with few clicks

Resources