App page
Requirements and Test Management for Jira
Cloud Server/Data Center
Requirements and Test Management for Jira

Cloud

Server/Data Center

Documentation
FAQ
Release notes
Migration to Cloud
Last updated May 3, 2025

NUnit integration

Java (NUnit) #1 example: using the test method name

Test code

In NUnit, you can include the RTM test case key in the test method name or use annotations to add metadata to your tests. In this example, the test method is named test1_TC_KEY_PR_156, where PR-156 is the Test Case issue key. Including the key in the test method name ensures that it appears in the test results, allowing RTM to map the test execution to the corresponding test case.

import org.junit.jupiter.api.Test;

public class ExampleTest {

    @Test
    // example that uses TC_KEY prefix
    public void test1_TC_KEY_PR_156() {
        // Test code here
    }

    @Test
    // example with only Test Case issue key
    public void test2_RTM_AUT_TEST_KEY_PR_156() {
        // Test code here
    }
}

Test Result File (NUnit XML) v2 After running the tests, NUnit can generate an XML report (TEST-example.xml) that looks like this:

<results>
    <test-suite type="Namespace" name="NUnit" executed="True" result="Success" success="True" time="0.807" asserts="0">
        <results>
            <test-case name="com.deviniti.example.ExampleTest_test1_RTM_AUT_TEST_KEY_PR_156" executed="True" result="Success" success="True" time="0.013" asserts="0" />
            <test-case name="com.deviniti.example.ExampleTest_test2_TC_KEY_PR_156" executed="True" result="Success" success="True" time="0.013" asserts="0" />
        </results>
    </test-suite>
</results>

Test Result File (NUnit XML) v3

<test-suite type="TestFixture" id="1000" name="ExampleTest" fullname="com.deviniti.example.ExampleTest" testcasecount="2" result="Success" time="0.119" total="2" passed="2" failed="0" inconclusive="0" skipped="0" asserts="0">
    <test-case id="1002" name="test1_RTM_AUT_TEST_KEY_PR_156" fullname="com.deviniti.example.ExampleTest.test1" result="Passed" time="0.000" asserts="0" />
    <test-case id="1003" name="test2_TC_KEY_PR_156" fullname="com.deviniti.example.ExampleTest.test2" result="Passed" time="0.000" asserts="0" />
</test-suite>

Java (NUnit) #2 example: printing patterns to console output

Test code

Another way to map tests is to print patterns to console output. Check Mapping tests to Test Cases for details.

import org.nunit.jupiter.api.Test;

public class ExampleTest {

    @Test
    public void testSumFunction() {
        // map this test to Test Case by Automation Test Key
        System.out.println("RTM_AUT_TEST_KEY=example.calculator.addFunction");
        // when creating Test Case from test results use summary below
        System.out.println("TC_SUMMARY=\"Calculate the sum of two numbers\"");
        // when creating Test Case from test results link it with requirement by issue key
        System.out.println("REQ_KEY=PR-109");
        
        // Test code here
    }
}

Test Result File (NUnit XML) v2

After running the tests, NUnit can generate an XML report (TEST-example.xml) that looks like this:

<results>
    <test-case name="com.deviniti.example.ExampleTest_test1" executed="True" result="Success" success="True" time="0.013" asserts="0">
        <reason>
            <message><![CDATA[RTM_AUT_TEST_KEY=example.calculator.addFunction
                TC_SUMMARY="Calculate the sum of two numbers"
                REQ_KEY=PR-109
            ]]></message>
        </reason>
    </test-case>
</results>

Test Result File (NUnit XML) v3

<test-suite type="TestFixture" id="1000" name="ExampleTest" fullname="com.deviniti.example.ExampleTest" testcasecount="1" result="Success" time="0.119" total="1" passed="1" failed="0" inconclusive="0" skipped="0" asserts="0">
    <test-case id="1002" name="test1_RTM_AUT_TEST_KEY_PR_156" fullname="com.deviniti.example.ExampleTest.test1" result="Passed" time="0.000" asserts="0">
        <output>
            <![CDATA[RTM_AUT_TEST_KEY=example.calculator.addFunction
                TC_SUMMARY="Calculate the sum of two numbers"
                REQ_KEY=PR-109
            ]]>
        </output>
    </test-case>
</test-suite>