question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple testNG tests run by @Factory are marked as "retries" instead of being separate

See original GitHub issue

I’m submitting a …

  • bug report
  • feature request
  • support request => Please do not submit support request here, see note at the top of this template.

What is the current behavior?

When running tests with TestNG @Factory annotation, multiple runs are considered as “retries” instead of appearing as separate test runs.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal

Run the following class:

import io.qameta.allure.Step;
import org.testng.Assert;
import org.testng.annotations.Factory;
import org.testng.annotations.Test;

public class TestPoc {
    int i = 1;

    public TestPoc() {

    }

    public TestPoc(int i) {
        this.i = i;
    }

    @Test
    public void stepFailDemo() {
        try {
            failStep();
        } catch (AssertionError e) {/*do nothing*/
        }
    }

    @Step("Failing step")
    private void failStep() {
        Assert.fail("Failing an inner step  " + i);
    }

    @Factory
    public Object[] myFactory() {
        return new Object[]{new TestPoc(5), new TestPoc(6),new TestPoc(7)};
    }
}

image

What is the expected behavior?

Expected behaviour - Tests should show as separate entities.

What is the motivation / use case for changing the behavior?

Current behaviour is a bug - This is running a data driven test for 3 separate test cases (different parameters for test method)

Please tell us about your environment:

Allure version 2.2.0
Test framework testng@6.11
Allure integration allure-testng@2.0-BETA16
Generate report using allure-maven@2.8
Report version 2.3.3

Other information

allure-results.zip

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:17 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
nitintsocialcommented, Aug 1, 2018

Kindly provide workaround for the same to show tests instead of retries in allure report.

2reactions
baevcommented, Apr 24, 2019

I just added brand new TestInstanceParameter annotation that can be used to add parameters from test instance:

import io.qameta.allure.Step;
import org.testng.Assert;
import org.testng.annotations.Factory;
import org.testng.annotations.Test;

public class TestPoc {
    @TestInstanceParameter("Interation") // will add a parameter with name Interation to each test result
    int i = 1;

    public TestPoc() {

    }

    public TestPoc(int i) {
        this.i = i;
    }

    @Test
    public void stepFailDemo() {
        try {
            failStep();
        } catch (AssertionError e) {/*do nothing*/
        }
    }

    @Step("Failing step")
    private void failStep() {
        Assert.fail("Failing an inner step  " + i);
    }

    @Factory
    public Object[] myFactory() {
        return new Object[]{new TestPoc(5), new TestPoc(6),new TestPoc(7)};
    }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple testNG tests run by @Factory are marked as "retries ...
Multiple testNG tests run by @Factory are marked as "retries" instead of being separate.
Read more >
Documentation - TestNG
If set to true, tests generated using this data provider are run in parallel. Default value is false. @Factory, Marks a method as...
Read more >
Retry Failed Test in TestNG with IRetryAnalyzer
In this article, we will learn how to retry failed test in TestNG with IRetryAnalyzer and also how to rerun all tests from...
Read more >
TestNG retry test in multithreaded environment - Stack Overflow
When I run only one test then retry mechanism works well (1 pass and 2 skipped). But when I run 5 tests as...
Read more >
Parameterization in TestNG using testng.xml - Selenium Easy
TestNG allows the user to pass values to test methods as arguments by using parameter annotations through testng.xml file. Some times it may...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found