N
Size: a a a
N
AA
N
AY
L
AA
public class RetryRule implements TestRule {
private static final String TAG = RetryRule.class.getSimpleName();
private final int retryCount;
public RetryRule(int retryCount) {
this.retryCount = retryCount;
}
@Override
public Statement apply(Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
Throwable caughtThrowable = null;
for (int i = 0; i < retryCount; i++) {
try {
base.evaluate();
return;
} catch (Throwable t) {
caughtThrowable = t;
Log.w(TAG, description.getDisplayName() + ": run " + (i + 1) + " failed");
}
}
Log.w(TAG, description.getDisplayName() + ": giving up after " + retryCount + " failures");
throw caughtThrowable;
}
};
}
}
NK
AP
AA
AP
AP
L
AA
L
AA
L
AV
A
АС
J