Skip to main content
All CollectionsAPI & Integrations
TestNG – How to use GitHub vansah-action for TestNG framework
TestNG – How to use GitHub vansah-action for TestNG framework
Updated over 3 months ago

The use of vansah-action is to send results generated from TestNG automation framework to Vansah installed on Jira workspace.

To use vansah-actions, there are few requirements such as

  • Jira Workspace with vansah installed

  • Project must be in GitHub Repo with Actions enabled

  • Project must be Maven configured

  • JDK 8 minimum is required

  • TestNG version must be 7.1.x or above

  • Use of maven surefire and compiler plugin is required

  • Use of Custom Attributes annotations in test class

  • Vansah Connect Token is required

Use of Vansah API Token

To authenticate with Vansah for Jira, connect token is required and should be saved under github secrets

To generate the token follow this Guide (Generate a API Token)

Use of Custom Attributes

Vansah-action to identify what test to fail or pass, we need to use custom attributes annotations

@Test(attributes = { 

@CustomAttribute(name = "Case Key", values = "DOT-C1"), @CustomAttribute(name = "Tested Issue", values = "DOT-1"), @CustomAttribute(name = "Tested Sprint", values = "DOT Sprint 1"), @CustomAttribute(name = "Tested Environment", values = "SYS")})

public void Addition_Test() {
int a = 3 , b = 2;
int sum = a + b ;
System.out.println("Addition of Two numbers are : " + sum); Assert.assertEquals(sum, 5);
}

You cannot change name values to something different as they are constant and case sensitive,

Following are the available constants

  • Case Key (Mandatory)

  • Tested Issue (Mandatory)

  • Tested Sprint

  • Test Environment

  • Test Version

Use of TestNG results.xml file

Vansah-action can only digest testng generated results.xml file with custom attributes, any change can cause failure.

here is the sample generated file

Use in Existing Automation Project

If above requirement are fulfilled then only we can proceed with this step.

we are assuming that the project is already in GitHub, so now will setup an workflow in GitHub.

For this you need to enable Actions in your repo.

To create a new workflow, if you are already using a workflow please go to step 5

1.Click on Actions and then click on New workflow

2.Search Maven in workflow, as we are using maven project.

3.Click on Configure and then the below screen will appear

4.Copy or Edit your yml file based on your info.

name: Java CI with Maven 

on:
push:
branches: [ "test" ]
pull_request: branches: [ "test" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn clean test

5.Now search for vansah-action in the right hand side panel (alternatively you can click on this link to go directly to the Github Action in marketplace)

6.Click on it and look for the installation procedure

7.Click on Copy Icon

8.Paste the following code after the end of file, locate your testngresults.xml and mention under testPaths

- name: Vansah TM Test Results Importer 
uses: testpoint/vansah-action

with:
vansahConnectToken: ${{ secrets.VANSAHCONNECTTOKEN }}
testFormat: "TESTNG" testPaths: ".\target\testng-results.xml"

9.Now trigger an event to run the workflow

Did this answer your question?