Page History
...
Mapping of fields from the report to the Test issue
NUnit XML TestNG XML report | Test in Jira |
---|---|
| Summary field |
| Generic Test Definition custom field |
categories | labels (except for the ones that match with Tests or requirements) |
"Test" property or category containing a Jira key of a Test | identification of Test issue key in Jira |
"Requirement" property or category containing a Jira key of a requirement | link to requirement |
...
Consider running some Tests implemented in the following C# class.
Code Block | ||||
---|---|---|---|---|
| ||||
namespace x { [TestFixture] public class CalculatorTests { [TestCase(1, 1, 2)]package com.xpand.java; import org.testng.Assert; import org.testng.annotations.Test; import org.testng.annotations.BeforeSuite; import org.testng.annotations.AfterSuite; import org.testng.annotations.DataProvider; import org.testng.Reporter; import org.testng.reporters.XMLReporter; import org.testng.ITestResult; import com.xpand.annotations.Xray; public class CalcTest { @BeforeSuite [TestCase(-1, -1, -2)] public void setUp() throws Exception { [TestCase(100, 5, 105)]} @AfterSuite public void [Category("CALC_1")] tearDown() throws Exception { [Category("fast")] } @DataProvider public [Property("Requirement", "CALC-69")] Object[][] ValidDataProvider() { return new [Property("Test", "CALC-10")]Object[][]{ public void CanAddNumbers(int a, int b { 1, 2, int3 expected)}, { { 2, 3, 4 }, Assert.That(Calculator.Add(a, b), Is.EqualTo(expected)); // error or the data itself :) } { [TestCase(-1, 1, 0)] } [TestCase(-1, -1, 0)]}; } [TestCase@Test(100,dataProvider 5, 95)]= "ValidDataProvider") @Xray(requirement = "CALC-1234", test = [Category("CALC_2-1")] public void CanSubtractCanAddNumbersFromGivenData(final int xa, final int yb, final int expectedc) { Assert.ThatassertEquals(Calculator.SubtractAdd(xa, yb), Is.EqualTo(expected)c); } @Test ... } } |
In the first Test, Xray would try to find a Test with the key "CALC-10". If it does not exist, the Test won't be created.
The test would be linked to the Requirement with key "CALC-69", using the "tests" association, if the requirement exists.
If there is a requirement with the key "CALC-1", it would create the link to that requirement. If "CALC-1" corresponds to a Test issue, then "CALC_1" is ignored.
If the Category "CALC_1" does not map to either a requirement or a Test, it would be added to the Test as a label.
In the second Test, a Generic Test with the summary "CanSubtract" would be created.
The Test is only created if no Test with same Generic Test Definition already exists or if "CALC-2" does not correspond to a Test issue.
If there is a requirement with the key "CALC-2", it would create the link to that requirement.
...
@Xray(requirement = "CALC-1234", test = "CALC-2")
public void CanAddNumbers()
{
Assert.assertEquals(Calculator.Add(1, 1),2);
Assert.assertEquals(Calculator.Add(-1, 1),0);
ITestResult result = Reporter.getCurrentTestResult();
result.setAttribute("requirement", "CALC-1234"); // Xray will try to create a link to this requirement issue
result.setAttribute("test", "CALC-2"); // Xray will try to find this Test issue and report result against it
result.setAttribute("labels", "core addition"); // Xray will add this(ese) label(s) to the associated Test issue
}
@Test
@Xray(requirement = "CALC-1235", labels = "core")
public void CanSubtract()
{
Assert.assertEquals(Calculator.Subtract(1, 1), 0);
Assert.assertEquals(Calculator.Subtract(-1, -1), 0);
Assert.assertEquals(Calculator.Subtract(100, 5), 95);
}
@Test
@Xray(requirement = "CALC-1236")
public void CanMultiplyX()
{
Assert.assertEquals(Calculator.Multiply(1, 1), 1);
Assert.assertEquals(Calculator.Multiply(-1, -1), 1);
Assert.assertEquals(Calculator.Multiply(100, 5), 500);
}
@Test
@Xray(requirement = "CALC-1237")
public void CanDivide()
{
Assert.assertEquals(Calculator.Divide(1, 1), 1);
Assert.assertEquals(Calculator.Divide(-1, -1), 1);
Assert.assertEquals(Calculator.Divide(100, 5), 20);
}
@Test
@Xray(test = "CALC-6")
public void CanDoStuff()
{
Assert.assertNotEquals(true, true);
}
} |
In the first Test, Xray would try to find a Test with the key "CALC-10". If it does not exist, the Test won't be created.
The test would be linked to the Requirement with key "CALC-69", using the "tests" association, if the requirement exists.
If there is a requirement with the key "CALC-1", it would create the link to that requirement. If "CALC-1" corresponds to a Test issue, then "CALC_1" is ignored.
If the Category "CALC_1" does not map to either a requirement or a Test, it would be added to the Test as a label.
In the second Test, a Generic Test with the summary "CanSubtract" would be created.
The Test is only created if no Test with same Generic Test Definition already exists or if "CALC-2" does not correspond to a Test issue.
If there is a requirement with the key "CALC-2", it would create the link to that requirement.
If the Category "CALC_2" does not map to either a requirement or a Test, it would be added to the Test as a label.
Code Block | ||||
---|---|---|---|---|
| ||||
package com.xpand.java;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.DataProvider;
import org.testng.Reporter;
import org.testng.reporters.XMLReporter;
import org.testng.ITestResult;
import com.xpand.annotations.Xray;
public class CalcTest {
@BeforeSuite
public void setUp() throws Exception {
}
@AfterSuite
public void tearDown() throws Exception {
}
@DataProvider
public Object[][] ValidDataProvider() {
return new Object[][]{
{ 1, 2, 3 },
{ 2, 3, 4 }, // error or the data itself :)
{ -1, 1, 0 }
};
}
@Test(dataProvider = "ValidDataProvider")
@Xray(requirement = "CALC-1234", test = "CALC-1")
public void CanAddNumbersFromGivenData(final int a, final int b, final int c)
{
Assert.assertEquals(Calculator.Add(a, b), c);
}
@Test
@Xray(requirement = "CALC-1234", test = "CALC-2")
public void CanAddNumbers()
{
Assert.assertEquals(Calculator.Add(1, 1),2);
Assert.assertEquals(Calculator.Add(-1, 1),0);
ITestResult result = Reporter.getCurrentTestResult();
}
@Test
@Xray(requirement = "CALC-1235", labels = "core")
public void CanSubtract()
{
Assert.assertEquals(Calculator.Subtract(1, 1), 0);
Assert.assertEquals(Calculator.Subtract(-1, -1), 0);
Assert.assertEquals(Calculator.Subtract(100, 5), 95);
}
@Test
@Xray(requirement = "CALC-1236")
public void CanMultiplyX()
{
Assert.assertEquals(Calculator.Multiply(1, 1), 1);
Assert.assertEquals(Calculator.Multiply(-1, -1), 1);
Assert.assertEquals(Calculator.Multiply(100, 5), 500);
}
@Test
@Xray(requirement = "CALC-1237")
public void CanDivide()
{
Assert.assertEquals(Calculator.Divide(1, 1), 1);
Assert.assertEquals(Calculator.Divide(-1, -1), 1);
Assert.assertEquals(Calculator.Divide(100, 5), 20);
}
@Test
@Xray(test = "CALC-6")
public void CanDoStuff()
{
Assert.assertNotEquals(true, true);
}
} |
Status
The status of the Test Run will be set based on the Test case result:
Test Cases (NUnit3.0) | Test Cases (NUnit2.6) | Test status | |
---|---|---|---|
Failed | Error | FAIL | |
Passed | Success | PASS | |
Other Cases | Other Cases | TODO |
...