Page History
...
Info | ||
---|---|---|
| ||
Xray supports TestNG 6.14 XML reports. |
TestNG Basic Concepts
In TestNG, you have Test methods, Parameterized Test methods, Test classes, Test groups, suites.
...
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") public void CanAddNumbersFromGivenData(final int a, final int b, final int c) { Assert.assertEquals(Calculator.Add(a, b), c); } @Test 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 } ... } |
In the first Test method, we can see an example of a parameterized test using a data provider. Xray would try to find a Test with the same Generic Test Definition, if it does not find one then it will create a Test issue.
In the second Test , a Generic Test with the summary "CanAddNumbers" would be created.The Test is only created if no method, Xray will try to find an existing Test having the issue key CALC-2. If it does not find one and no Test with same Generic Test Definition already exists or if "CALC-2" does not correspond to a Test issuethen a Generic Test with the summary "CanAddNumbers" would be created.
If there is a requirement with the key "CALC-1234", it would create the link to that requirement.
...
Test Cases | Test status | |
---|---|---|
Failed | Error | FAIL |
Passed | Success | PASS |
Other Cases | Other Cases | TODO |
Note: Test Cases cases with the status FAIL may have a failure message displayed in the Test Run screen, under the Results section.
If the same Test Case case has been executed in multiple Test Suitestmes, then the result for each Test Suite context will be shown. A parameterized Test will also appear with its own specific contextcontexts.
<REPLACE IMAGE BELOW>
Whenever a Test Case is executed in multiple contexts, the overall status of the Test Run will be calculated as a joint value.
...