Giter Club home page Giter Club logo

tm4j-testng-integration's Introduction

tm4j-testng-integration

A quick proof-of-concept for combining TestNG listeners, custom annotations, & the REST API provided by TM4J to ship off automated test results as they occur.

Prerequisites

This proof-of-concept uses two different dedicated libraries (besides TestNG) managed by Maven:

  1. SendGrid's HTTP client for Java
  2. antonsjava's json library

(As well as inspiration for the custom TestData annotation from letsrokk's tm4j-hooks library—thanks, Raghu!)

A TM4J-provided API key is also required to be configured as an environment variable for this to work as-is. An API key can be obtained pretty easily for a given project in JIRA by navigating to your profile and clicking the Test Management for JIRA API Keys option.

On Windows, the environment variable can be initialized from the CLI:

setx TM4J_API_KEY "YOUR_KEY_HERE"

Usage

Integrating TM4J is easy! Just add a separate @TestData annotation with the relevant TM4J key to each @Test that needs to be added to the automated test cycle.

@TestData(key="QAT-T1")

Configure the testng.xml with whatever tests need to be run & then execute from the IDE or the command line (—the listeners are configured in BaseTest for any child tests to extend & can be run easily from the IDE, but are also integrated in the TestNG configuration file otherwise.)

Sample Output

[RemoteTestNG] detected TestNG version 7.3.0
[DEBUG] TEST CYCLE: QAT-R47
[DEBUG] Connector assigned & configured!
====StatusChangeTest====
[DEBUG] Starting the test...
[DEBUG] TEST STATUS (REQUEST): {"projectKey":"QAT","testCaseKey":"QAT-T2",
"testCycleKey":"QAT-R47","statusName":"Fail","testScriptResults":[{"statusName":"Fail"}]}
[DEBUG] TEST STATUS (RESPONSE): 201
[DEBUG] Test failed, shipping result to connector for processing.
====LoginTest====
[DEBUG] Starting the test...
[DEBUG] Test completed!
[DEBUG] TEST STATUS (REQUEST): {"projectKey":"QAT","testCaseKey":"QAT-T1",
"testCycleKey":"QAT-R47","statusName":"Pass","testScriptResults":[{"statusName":"Pass"}]}
[DEBUG] TEST STATUS (RESPONSE): 201
[DEBUG] Test passed, shipping result to connector for processing.
PASSED: LoginTest
FAILED: StatusChangeTest

The Laundry List

  • Look into breaking out the hardcoded project key from Connector.java to some sort of separate configuration file so that multiple project types can be used in a single run—maybe just fold into the TestData custom annotation type?

tm4j-testng-integration's People

Contributors

raftacon avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.