This article is a follow up from my previous article in setting up Allure locally with NUnit. I made a brief mention of the Allure TeamCity plugin but encountered difficulties in getting it to work and didn't have much time to look into getting around it. Lets get stuck in with a brief recap/ some initial steps to take. Install NUnit 2.6.4 and the compatible NUnit adapter into your allure ...
Getting some decent test reporting can be painful when working with Visual Studio and particularly with MS Test as the framework as newer versions of Visual Studio don’t appear to produce a *.trx file anymore.
Using NUnit we can generate some fancy graphs and stats using the Allure framework with NUnit.
- Firstly we need to download and install NUnit: www.NUnit.org
- Secondly we need the Allure NUnit adaptor, follow instructions here: Allure Framework Adaptor for NUnit
- The Allure Command Line Interface is needed, get it from here: Allure CLI
- Java JDK needs to be installed and specified correctly in your JAVE_HOME variable in your environment
Allure produces an XML file which can use that to generate a HTML report, there is also an adaptor for MS Test but it’s an extra hoop to jump through as it converts a *.trx into a XML which you then have to generate.
The NUnit adaptor generates the XML file to a directory when your tests are run with NUnit.
- Last of all we need the Allure Command Line Tool to generate the HTML report: Allure Command Line Tool
To generate the report run cmd in your Allure.bat directory and run the command:
allure report generate –v 1.4.1 path/to/directory/with/xml/files
Note: It is important you DO NOT paste this command in – type it out the long way – You can paste in the path to the XML files though.
You should see the following message:
Successfully generated report to [//Path to generated report]
Go to the directory and open the HTML report in Firefox as other browsers will not work with some of the Ajax requirements locally.
This is your generated report! You might also want to publish it as an artefact in your Team City CI build, with the Allure Team City Plugin.
NOTE: If you are using Specflow with NUnit be sure to install nuget package NUnit.Runners. If this breaks your build, go download the binary version of NUnit (http://www.nunit.org/index.php?p=download) and copy over both nunit.core.dll – nunit.core.interfaces.dll to be referenced in your solution. This will ensure NUnit sees your [AfterTestRun] hook and perform all necessary teardown tasks.
Collating multiple sets of results into one report
If you have the need to merge multiple sets of results into a single report this can be done easily by copying the generated XML files out to another directory, running another set of tests and then copying the previous files back over.
When you generate the report from the directory with two sets of XML files, Allure will mash it all together into one report.
You could also try Running Multiple Assemblies with NUnit but this is not recommended in my opinion.