Allure TestNG Retry Listener

Implementation of ITestListener to allow retry functionality for combination of Allure Framework and TestNG Framework

License

License

Categories

Categories

TestNG Unit Testing
GroupId

GroupId

com.github.paulakimenko
ArtifactId

ArtifactId

allure-testng-retry-listener
Last Version

Last Version

0.1
Release Date

Release Date

Type

Type

jar
Description

Description

Allure TestNG Retry Listener
Implementation of ITestListener to allow retry functionality for combination of Allure Framework and TestNG Framework
Project URL

Project URL

https://github.com/paulakimenko/allure-testng-retry-listener/
Source Code Management

Source Code Management

https://github.com/paulakimenko/allure-testng-retry-listener/

Download allure-testng-retry-listener

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.paulakimenko/allure-testng-retry-listener/ -->
<dependency>
    <groupId>com.github.paulakimenko</groupId>
    <artifactId>allure-testng-retry-listener</artifactId>
    <version>0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.paulakimenko/allure-testng-retry-listener/
implementation 'com.github.paulakimenko:allure-testng-retry-listener:0.1'
// https://jarcasting.com/artifacts/com.github.paulakimenko/allure-testng-retry-listener/
implementation ("com.github.paulakimenko:allure-testng-retry-listener:0.1")
'com.github.paulakimenko:allure-testng-retry-listener:jar:0.1'
<dependency org="com.github.paulakimenko" name="allure-testng-retry-listener" rev="0.1">
  <artifact name="allure-testng-retry-listener" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.paulakimenko', module='allure-testng-retry-listener', version='0.1')
)
libraryDependencies += "com.github.paulakimenko" % "allure-testng-retry-listener" % "0.1"
[com.github.paulakimenko/allure-testng-retry-listener "0.1"]

Dependencies

compile (2)

Group / Artifact Type Version
ru.yandex.qatools.allure : allure-testng-adaptor jar 1.4.0
org.testng : testng jar 6.8

test (1)

Group / Artifact Type Version
org.mockito : mockito-all jar 1.8.4

Project Modules

There are no modules declared in this project.

#Allure TestNG Retry Listener

Implementation of TestNG ITestListener to allow "Retry Functionality" for combination of Allure Framework and TestNG Framework. See JavaDocs here (TBD).

##Features:

  • If test has been retried, its result status would be changed from "Failed"("Broken") to "Pending", with all saved steps and attachments
  • If test failed and it hasn't "retry ability", its result status wouldn't be changed
  • User can use SimpleRetryAnalyzer which works with TestNG dataProviders and gets MAX_RETRY_COUNT from system properties (see the example below)
  • User can implement IAllureRetryAnalyzer, or extend from AbstractAllureRetryAnalyzer to set the rule for retry (to write custom analyzer)
  • There is RetryUtils.getResultHash() method which returns special hashcode from ITestResult instance (to write custom analyzer)

##How-to:

Simple usage example:

@Listeners(RetryListener.class)
public class ExampleTest {
    @Test(retryAnalyzer = SimpleRetryAnalyzer.class)
    public void test() {
        // test logic
    }
}

To apply RetryAnalyzer for whole suite:

@BeforeSuite(alwaysRun = true)
public void setUpSuite(ITestContext context) {
    for (ITestNGMethod method : context.getAllTestMethods()) {
        if (method.getRetryAnalyzer() == null) {
            method.setRetryAnalyzer(new SimpleRetryAnalyzer());
        }
    }
}

Set MAX_RETRY_COUNT for SimpleRetryAnalyzer example:

System.setProperty(SimpleRetryAnalyzer.RETRY_COUNT_PROPERTY_KEY, "2");
    // "alluretestng.retrylistener.retryCount" property key

Custom RetryAnalyzer example:

public static class TestRetryAnalyzer extends AbstractAllureRetryAnalyzer {
    private static final int MAX_RETRY_COUNT = 1;
    private int retryCount;

    @Override
    public boolean retry(ITestResult result, boolean getRetryAbilityOnly) {
        if (retryCount < MAX_RETRY_COUNT) {
            if (!getRetryAbilityOnly)
                retryCount++;
            return true;
        }
        return false;
    }
}

Contact

Mail: [email protected]

Versions

Version
0.1