NUnit Framework Integration

Starting October 11, 2024 (Zephyr Enterprise 8.2), the Zephyr Enterprise documentation moved from its current location on Atlassian to a dedicated, standalone Zephyr Enterprise documentation page. Please see:

NUnit is a unit-testing framework for all .NET languages. For more info on NUnit, see here.

The NUnit integration relies on the JUnit integration. We will explain how to generate a JUnit XML results file from NUnit so you can use the JUnit to push your results.

Writing NUnit tests

Here is an example. Consider a class named UnitTest.cs:

using NUnit.Framework; namespace UnitTest { public class Tests { [SetUp] public void Setup() { } [Test] public void Substract() { double res = 10 - 10; Assert.AreEqual(res, 0); } [TestCase(2, 2, 4)] [TestCase(0, 5, 5)] public void Add(double a, double b, double c) { double res = a + b; Assert.AreEqual(res, c); } [Test] public void Divide() { double res = 10 / 5; Assert.AreEqual(res, 2); } } }

To summarize, the rules for matching a test method to a test case are: Try to match a test case by using the method's fully qualified name.

Uploading results to Zephyr Enterprise

Nunit report file does not support JUnitXml format, however, there is a way to convert NUnit3 results to JUnit-style results.

To instruct Nunit to execute the tests and generate the JUnit XML results file, it is required to execute nunit-console like this:

nunit3-console.exe YourTestAssembly.dll --result=junit-results.xml;transform=nunit3-junit.xslt

The command line above will execute the tests and generate the JUnit XML results file junit-results.xml. More info here.

Once the NUnit tests have been executed, the results can be uploaded to the Zephyr Scale. There are two options for uploading test results:

Once the Nunit Framework tests have been executed, the results can be uploaded to Zephyr Enterprise.

  • Using API, we can upload the JUnit XML results file generated by NUnit Framework.

  • Using Vortex Suite Automation containing JUnit XML results file generated by NUnit Framework.

  • Using Vortex FolderWatcher file containing multiple JUnit XML results files generated by NUnit Framework.

If the XML file Upload does not work, we could create a Custom template for the Robot Framework depending on the Junit XML output using the API
Example Body of the Custom Template:-

{ "name": "nunit", "jsonTemplate": "[{\"statuses\":[{\"statusId\":\"2\",\"attachmentText\":\"\",\"statusString\":\"Failed\",\"status\":\"${TestRun.Results.UnitTestResult:outcome}\"},{\"default\":true,\"attachmentText\":\"Name: ${TestRun.Results.UnitTestResult:testName}\",\"statusId\":\"1\"}],\"skipTestcaseNames\":\"\",\"packageName\":\"\",\"testcase\":{\"name\":\"${TestRun.Results.UnitTestResult:testName}\"}}]" }