This dependency gathers basic build information and useful artifacts (titled values, user defined files, screenshoots, stack traces) for further processing by Jenkins Test Management plugin.
The key thing is that this adapter are working in tandem with Jenkins Test Management plugin which processes gathered information and updates Jira issues via REST API.
At this time, Test Management adapter installation is possible only in local repository. Unfortunately, the adapter has not yet been placed into the Maven Central Repository.
mvn install::install-file -Dfile=test-management-adapter-1.7-jar-with-dependencies.jar
-DgroupId=com.epam.jira
-DartifactId=test-management-adapter
-Dversion=1.7
-Dpackaging=jar
For copy-paste: mvn install::install-file -Dfile=test-management-adapter-1.7-jar-with-dependencies.jar -DgroupId=com.epam.jira -DartifactId=test-management-adapter -Dversion=1.7 -Dpackaging=jar
After that you need to add next dependency to your pom-file:
<dependency>
<groupId>com.epam.jira</groupId>
<artifactId>test-management-adapter</artifactId>
<version>1.7</version>
</dependency>
Add ExecutionListener
to your TestNG listeners by one of the following methods:
<build>
<plugins>
[...]
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<configuration>
<properties>
[...]
<property>
<name>listener</name>
<value>com.epam.jira.testng.ExecutionListener</value>
</property>
[...]
</properties>
</configuration>
</plugin>
[...]
</plugins>
</build>
@Listeners({com.epam.jira.testng.ExecutionListener.class})
public class TestClass {
// ...
}
<?xml version="1.0" encoding="UTF-8"?>
<suite name="Suite" parallel="false">
<listeners>
<listener class-name="com.epam.jira.testng.ExecutionListener" />
</listeners>
<test name="Test">
<classes>
[...]
</classes>
</test>
</suite>
public static void main(String[] args) {
TestNG testNG = new TestNG();
testNG.setTestClasses(new Class[] { TestClass.class });
testNG.addListener(new ExecutionListener());
testNG.run();
}
Mark tests with @JIRATestKey annotation and specify corresponding issue key as its key parameter value.
@Test
@JIRATestKey(key = "EPMFARMATS-1010")
public void testSomething() {
Assert.assertTrue(true);
}
You can disable this annotation using its disabled
option
You will need to initialize Screenshoter class with WebDriver instance in order to attach screenshots to JIRA issue in the fail cases.
@BeforeClass
public void initialize() {
Screenshoter.initialize(driver);
}
You can disable screenshots on failure for a certain test using JiraTestKey disableScreenshotOnFailure
option
You can store useful informatian such as string values (with titles) or files using JiraInfoProvider class.
JiraInfoProvider.saveFile(new File("path_to_file"));
JiraInfoProvider.saveValue("Title", "Some value");
You can rerun your failed tests if needed. You can do that by one of the following methods:
You can do it in the same way as Execution Listener
@JIRATestKey(key = "EPMFARMATS-1010")
@Test(retryAnalyzer = RetryAnalyzer.class)
public void testSomething() {
...
}
If you want to rerun your test several times, you will need to use JiraTestKey retryCountIfFailed
option (default value is 1). The count of reruns will be desplayed in your Test report summary field.
@JIRATestKey(key = "EPMFARMATS-1010", retryCountIfFailed = 2)
@Test(retryAnalyzer = RetryAnalyzer.class)
public void testSomething() {
...
}
After running the tm-testng.xml
results file with attachments will be created in your project target
directory.