Master Disaster
Master Disaster

Reputation: 769

Testing two activities with Robolectric 4 and Espresso

I am just wondering if I can write tests in Robolectric 4 that I can test full integration between Activities.

I need to open FirstActivity because I have to get full data from network API and then my application starts SecondActivity that is using data from FirstActivity. I do not pass data in bundle.

So we scenarios should look like: 1. Open first activity 2. Open second activity 3. Check if button is visible (Espresso) 4. Next step to test flow

I have test written in Espresso (Automated Test) and I can do everything what I wrote above. Is it possible to make similar test with Robolectric?

Does Robolectric have idea to test only one activity without integration for another?

Upvotes: 1

Views: 495

Answers (1)

Stanislav Kinzl
Stanislav Kinzl

Reputation: 420

I don't think that is possible with Robolectric 4.0.2, though you can test if the intent to move to another activity was created, which may serve as a substitution. (If you wish to test the transition was successful). But yea you have to make 2 classes with 2 different ActivityRules in order to test this.

Upvotes: 1

Related Questions