Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@Rule is not working while running tests using CucumberWithSerenity.class #2995

Open
Ramesh1103 opened this issue Dec 16, 2022 · 2 comments
Open

Comments

@Ramesh1103
Copy link

I am trying to rerun failed test scenario immediately after failure.
i have implemented Test Rule to rerun failed scenario but while running with maven command its unable to identify @rule

`public class RetryRule implements TestRule {
private int retryCount;
public RetryRule(int retryCount) {
this.retryCount = retryCount;

}
public Statement apply(Statement base, Description description) {
	       return statement(base, description);
}
private Statement statement(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            Throwable caughtThrowable = null;
            // implement retry logic here
            Log.info("retryCount: "+retryCount);
            for (int i = 0; i < retryCount; i++) {
                try {
                    base.evaluate();
                     return;
                    
                }
                catch (Throwable t) {
                    caughtThrowable = t;
                    Log.info(description.getDisplayName() + ": run " + (i + 1) + " failed.");
                }
            }
            Log.info(description.getDisplayName() + ": Giving up after " + retryCount + " failures.");
            throw Objects.requireNonNull(caughtThrowable);
        }
    };
}`

i am using serenity 3.4.2 and Junit 4.13.2

@wakaleo
Copy link
Member

wakaleo commented Dec 16, 2022

I've never tried this, I have no idea if it is supported or not. If you are running with Cucumber it will most likely not do what you expect it to do.

@Ramesh1103
Copy link
Author

Thanks @wakaleo it is not supporting with cucumber as well ,we can able to generate only failed scenario feature files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants