Can NUnit console runner pass some command line arguments to nunit-agent? - nunit

We use the NUnit console to run our tests in Jenkins and we have many projects that share some tests. We want to be able to run the tests concurrently and to do that we need the tests to look at different databases.
I would like to pass in the project name to the nunit-agent which wouldn't know how to use it, but we would be able to fetch that from the command line arguments running the test and decide which database to look at.
I am open to suggestions.
We currently use "C:\Program Files (x86)\NUnit.org\nunit-console\nunit3-console.exe" Path\Tests.dll --result=nunit-result1.xml to run the tests

nunit-agent uses arguments to pass information that NUnit needs. For passing information to the test, the standard way is to use the --params command-line option and then access the values from your tests by means of TestContext.Parameters.

Related

Store results of unit test run into variables

I have a TeamCity build configuration that builds a C# project, runs some unit tests, and then does some extra things. My question is: Can I get information about my unit test run stored into build configuration variables (i.e. how many tests were run, how many were successful, how many failed, how many were skipped) so that I can then check these variables in a PowerShell script in later build steps and perform different actions depending on how many tests have passed?
AFAIK the best way is to ask these information directly to teamcity server using its REST API (pay attention, maybe the build locator could be a little be tricly to be found, if the build is still running).
By other hand, you can parse your NUnit test result file (or files if you run more than one NUnit test runner step in your build) inside your build agent machine.

ReSharper and NUnit's multiple domains

I recently had to enable this option in ReSharper:
Use separate AppDomain for each assembly with tests
Looking at the NUnit documentation, I suspect the option above executes NUnit with the parameter "domain/multiple", for which "a separate test domain is created for each assembly".
Could you please confirm me that is true?
Yes, this option corresponds to the /domain=Multiple command line parameter.
Note that ReSharper doesn't use the console runner. Instead it directly links the NUnit assemblies.

Running NCover from code

Is it possible to run NCover automatically from code instead of running NCover manually or via command line?
Here is the scenario, I have written a few tests, I execute all the tests and after the tests are completed, NCover should run automatically for that particular test project and store the coverage report as an XML in a location.
Is this possible to do? Kindly help.
Running NCover from the command line was the only option with NC3. When we updated NC4 the default works like this --> you create a project, the NCover service watches for a process to start that meets the match rules defined in the project, and then collects coverage on it.
This doc may be of some help: http://www.ncover.com/support/docs/desktop/user-guide/coverage_scenarios/how_do_i_collect_data_from_nunit
If you have more questions, please reach out to us at support#ncover.com.

Can I group by full class name my tests on NUnit or MSTest using command line?

The most of my tests uses database integration with NDbUnit and the isolation mode I use is grouping by them full class name.
Now, I need this config runs on command line 'cause I'll use Jenkins CI.
Is there any way to do this?
You can do this on the mstest.exe commandline using /test
mstest /testcontainer:TestProject1.dll /test:TestProject1.Unittest2
This will execute all the tests within the UnitTest2 class.
If you are using nunit-console.exe, then you can by Category. There is documentation on what you can send to the runner here (http://www.nunit.org/index.php?p=consoleCommandLine&r=2.2). You will likely want to use the /include and /exclude flags.

Is it possible to suppress NAnt's exec task's "[exec]" console output prefix

I'm trying to integrate Robot Framework (an acceptance testing framework) with TeamCity. In order to do this it needs to send messages to the console output which TeamCity will then read and return realtime test progress/results. I'm doing this by calling the command line to run the tests with a simple exec task. Everything seemed to be working other than I was only getting the results at the end of the run and not on the fly.
After a bit of struggling with NAnt I swapped to using MSBuild and everything worked first time.
I have what I need now, but for completeness I'd like to find out why I couldn't get it working with NAnt. As far as I can tell the issue is that NAnt is prefixing all console output with [exec]. Is it possible to suppress this?
I don't think the console output is configurable.
NAnt is open source: you could fork your own copy and/or submit a feature patch.