AIO Tests allows easy reporting of TestNG results by supporting importing the testng-results.xml. This article discusses how to import TestNG results and map them to tests existing in AIO Tests.
...
It is often, but not solely, combined with Selenium/Webdriver to drive Java-based tests. With its powerful features of data-driven testtests, parallel runs, flexible setup/teardown, and inbuilt reporting, it has become one of the most used Java frameworks alongside JUnit.
...
Sample TestNG Report of a simple single test. The report gives information on total tests, groups of the tests, their statuses, and duration.
Expand | |||||
---|---|---|---|---|---|
| |||||
|
...
If running through an IDE, check the settings for the TestNG configuration and enable default reporters if not enabled.
Expand | ||
---|---|---|
| ||
...
Status Mapping TestNG → AIO Tests
TestNG | AIO Tests |
---|---|
PASS | Passed |
FAIL | Failed |
SKIP | Not Run |
SKIP due to retry | (n-1) runs - Marked as failed [Note: TestNG shows them as skipped] |
...
Anchor | ||||
---|---|---|---|---|
|
In going with the simplicity advantage of AIO Tests, the TestNG integration has been designed as a simple and non-intrusive integration, without any extra dependency or coding required.
...
Below is a list of various scenarios that TestNG offers and a way to capture those in AIO Tests:
1. Normal
...
Standalone Case
Groups can be used to specify the AIO Tests key. In the below example,
“AT-TC-25” has been added as a group, which maps to an existing case in AIO Tests.
...
There can be many variations to data provider cases:3.
a. Each data in dataprovider is one manual case. TestNG runs the below test 3 times with different data supplied by the Data Provider method. In this case, with each data, the corresponding manual case key needs to be specified eg.
...
Below shows the dataprovider providing AT-TC-29 to 31.
Code Block |
---|
public class ForestCreatorTests { @DataProvider(name = "saplingSupplier") public Object[][] testDataProvider() { return new Object[][] { { "Baobab", "AT-TC-29"}, { "Palm" , "AT-TC-30"}, { "Banyan", "AT-TC-31"}, }; } @Test(dataProvider = "saplingSupplier") public void testSpecificTreePlantation(String treeName, String aioCaseKey) { //Your test goes here ForestCreator fc = new ForestCreator(); fc.plantSpecificTree(treeName); Assert.assertTrue(true, "Tree successfully planted"); } } |
...
c. Mixed Bag Some data point to the same
...
Info |
---|
AIO APIs expose a parameter, while uploading results, to specify whether multiple results of a case in a results.xml should be captured as separate runs of the same case or just capture the last run’s result. To know more, jump to Importing Results. |
Code Block |
---|
public class ForestCreatorTests {
@DataProvider(name = "saplingSupplier")
public Object[][] testDataProvider() {
return new Object[][] {
{ "Baobab"},
{ "Palm" },
{ "Banyan"},
};
}
@Test(dataProvider = "saplingSupplier", groups = "AT-TC-33")
public void testSpecificTreePlantation(String treeName) {
//Your test goes here
ForestCreator fc = new ForestCreator();
fc.plantSpecificTree(treeName);
Assert.assertTrue(true, "Tree successfully planted");
}
} |
3.c. Mixed Bag Some data point to the same case, whereas some point to individual manual cases.
...
case, whereas some point to individual manual cases.
In this case, a combination of groups and data provider keys can be used. In the example below, AT-TC-33 has been added to @Test and AT-TC-34 has been added with dataprovider data. In this case, Baobab and Banyan would report results for AT-TC-33, and “Palm” would report result to results for AT-TC-34.
Code Block |
---|
public class ForestCreatorTests { @DataProvider(name = "saplingSupplier") public Object[][] testDataProvider() { return new Object[][] { { "Baobab", ""}, { "Palm", "AT-TC-34" }, { "Banyan",""}, }; } @Test(dataProvider = "saplingSupplier", groups = "AT-TC-33") public void testSpecificTreePlantation(String treeName, String aioCaseKey ) { //Your test goes here ForestCreator fc = new ForestCreator(); fc.plantSpecificTree(treeName); Assert.assertTrue(true, "Tree successfully planted"); } } |
3.d. Dataprovider case mapping to multiple manual casecases
Comma-separated case keys can be provided to map a single data provider-driven case to multiple AIO tests. In the example below, the result of “Baobab” would update two cases - AT-TC-40, and AT-TC-42.
In total, these 3 tests would translate to 4 tests in Cycle executions.
...
4. Multiple invocation Counts
Same The same case gets executed multiple times. In the below example, based on the option selected while uploading results, 5 runs can be created for AT-TC-25 or the last result can be captured in one run.
Code Block |
---|
@Test(groups = {"P2","AT-TC-25"}, invocationCount = 5, description = "Verify no random failures while planting trees") public void testPlantTreeSeq() { ForestCreator fc = new ForestCreator(); int plantedTrees = fc.plantTrees(1); Assert.assertEquals(plantedTrees, 1, "Verify tree got planted successfully"); } |
Mapping a
...
Case to a
...
Folder
Users have the option to designate a default folder for newly created cases. They can also define a mapping between a case and a folder by simply adding a group starting with the prefix @AIO-FOLDER-
and mentioning the folder hierarchy. Folder hierarchy can be separated using /
, for example - @AIO-FOLDER-Reports/Audit log.
Info |
---|
...
This functionality is applicable only: |
...
|
...
|
Additionally, if configured, this will supersede the default folder setting.
Mapping using the default folder option
...
Post execution of a TestNG suite, the testng-results.xml file can be uploaded either via
Import Results- REST API - REST API call using multipart form-data to upload file
Import Results- Cycle Tab - Importing results file from the Cycles tab of the AIO Tests app
Please follow the above links to continue to import results using either of the options.
...