ActivityTestRule is deprecated
Mular8 opened this issue · 1 comments
Mular8 commented
Since ActivityTestRule is deprecated in favour of ActivityScenario, is there any way to run @AllowFlaky with ActivityScenario instead?
// Use a RuleChain to wrap your ActivityTestRule with a FlakyTestRule
private ActivityTestRule<FlakyActivity> activityRule = new ActivityTestRule<>(FlakyActivity.class);
private FlakyTestRule flakyRule = new FlakyTestRule();
@Rule
public RuleChain chain = RuleChain.outerRule(flakyRule)
.around(activityRule);
// Use @AllowFlaky to let flaky tests pass if they pass any time.
@Test
@AllowFlaky(attempts = 5)
public void some_flaky_test() throws Exception {
// ...
}
Sloy commented
Hi @Mular8. You can still use the FlakyTestRule
with ActivityScenario
. The rule will relaunch everything inside your @Test
function, so you should be fine.
At the end of this article I showed how we launched tests using ActivityScenario
in a way that works with FlakyTestRule
.