Search code examples
androidfunctional-testingrobotium

Robotium: How to continue running test cases without restarting the app after each test?


In my test class, i have multiple test cases written. Now when I run the test project, after each test case the app is getting stopped and started again. In teardown I am calling solo.finishOpenedActivities().

I want to run all test cases without closing the activities.

I tried to remove solo.finishOpenedActivities from the tearDown method. In that case the next testCases are not getting executed and the test hangs after the first one.

So what is the proper way to have multiple test cases and not close the activities and continue running all the tests?


Solution

  • If the functionalities between your test cases are dependent on each other, then instead of writing them in separate testcases, write different functions related to different functionality and call then in same testcase according to their order of execution.

    Because, after completion of each testcase, robotium will definitely close the activity and start a new activity for the other testcase.