Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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
titleSample testng-results.xml
Code Block
languagexml
<?xml version="1.0" encoding="UTF-8"?>
<testng-results ignored="0" total="1" passed="1" failed="0" skipped="0">
  <reporter-output>
  </reporter-output>
  <suite started-at="2020-08-04T15:08:54 IST" name="TngSuite" finished-at="2020-08-04T15:08:54 IST" duration-ms="46">
    <groups>
      <group name="P0">
        <method signature="ForestCreatorTests.testPlantTree()[pri:0, instance:com.aio.tests.ForestCreatorTests@74fe5c40]" name="testPlantTree" class="com.aio.tests.ForestCreatorTests"/>
      </group> <!-- P0 -->
    </groups>
    <test started-at="2020-08-04T15:08:54 IST" name="Testing first level" finished-at="2020-08-04T15:08:54 IST" duration-ms="46">
      <class name="com.aio.tests.ForestCreatorTests">
        <test-method signature="testPlantTree()[pri:0, instance:com.aio.tests.ForestCreatorTests@74fe5c40]" 
        started-at="2020-08-04T15:08:54 IST" name="testPlantTree" finished-at="2020-08-04T15:08:54 IST" 
        duration-ms="8" status="PASS">
          <reporter-output>
          </reporter-output>
        </test-method> <!-- testPlantTree -->
      </class> <!-- com.aio.tests.ForestCreatorTests -->
    </test> 
  </suite> 
</testng-results>

...

If running through an IDE, check the settings for the TestNG configuration and enable default reporters if not enabled. 

Expand
titleIntelliJ example to enable default reporters
IntelliJ settingsImage Removed

...

image-20200804-100933.pngImage Added

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]
nth run - Status based on above 3 statuses.

...

Anchor
map
map
Mapping Automated TestNG Tests to AIO Tests

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.

  1. 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.

...

  1. 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");
    }
}

...

  1. 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.

...

  1. 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:

...

  • If a new case is generated through the import process.

...

  • If the folder structure specified in the tag already exists.

Additionally, if configured, this will supersede the default folder setting.

  1. Mapping using the default folder option

...

Post execution of a TestNG suite, the testng-results.xml file can be uploaded either via

Please follow the above links to continue to import results using either of the options.

...