1

I just try Espresso for android with cucumber but I found an issue. I have 2 activities (HomeActivity and ResultActivity) in this scenario. This 2 scenario located on 1 .feature files.

Feature : Click button in home screen.  

Scenario: Open result page.  
Given user in home screen <-- HomeActivity.  
When user click next.  
Then user will see result page. <-- ResultActivity. 

Scenario :  Open Tutorial page.  
Given user in home screen.
When user click skip.  
Then user will see tutorial page.  

My question is why second scenario homeActivity not opened and @before not working ? Or the issue occur in @after first scenario ?

    @Rule
    public ActivityTestRule<HomeActivity> activityTestRule = new ActivityTestRule<>(
        HomeActivity.class);

    private Activity activity;

    @Before("@abc-feature")
    public void setup() {
        activityTestRule.launchActivity(new Intent());
        activity = activityTestRule.getActivity();
    }

    @After("@abc-feature")
    public void tearDown() {
        activityTestRule.finishActivity();
    }  
    @Given("^User in home screen$")
    public void userInHomeScreen() {
        assertNotNull(activity);
    }

Currently my espresso always failed for 2nd scenario. Thanks for your help and your attention. Regards.

Fatur
  • 21
  • 5

0 Answers0