package com.atlassian.bitbucket.test;

import com.atlassian.bitbucket.rule.RepeatRule;
import com.atlassian.bitbucket.test.rules.RetryRule;
import org.junit.rules.TestRule;

import java.util.List;

/**
 * A func test that will retry a failing test a configurable number of times.
 */
public abstract class BaseRetryingFuncTest extends BaseFuncTest {
    @Override
    protected final List<TestRule> getRuleChain() {
        return TestRuleOrderingSyntax.outerRules(
                new RepeatRule(),
                new RetryRule())
                .around(getRetryRuleChain());
    }

    /**
     * The list of rules that run around the test method and will be re-run if a test method is re-run.
     */
    protected List<TestRule> getRetryRuleChain() {
        return super.getRuleChain();
    }
}
