2

I want to write a test for persistent storage. The implementation details can change, for example, the code can switch from SharedPreferences to file-based storage or sqlite, but an in memory only data structure should NOT work (because it might be forgotten between activity restarts).

I want to add a automation test for this behavior, how should I stimulate app restart?

serv-inc
  • 35,772
  • 9
  • 166
  • 188
cheng yang
  • 1,692
  • 3
  • 12
  • 21

1 Answers1

0

Lifecycle Testing with Robotium: Killing and Restarting Activity might work for you.

You can restart a stopped activity using

launchActivity("com.testRestart", testactivity.class, null);

and stop the activity (using Robotium) with

solo.goBack();
Community
  • 1
  • 1
serv-inc
  • 35,772
  • 9
  • 166
  • 188