4

I have the following code in my activity:

@Override
protected void onResume() {
    super.onResume();
    initLoaders();
}

How can I test this code using Robotium/Espresso or may be any other testing tools? I want to verify that initLoaders gets called every time the activity is resumed (in case I accidentally delete this code later, for example).

netimen
  • 4,199
  • 6
  • 41
  • 65
  • If you're going to use Robotium, I suggest you write tests that verify the application's behavior. For example check that the right activity or the right text show up when they're supposed to. The best robotium tests don't need to know anything about the internals of the app's code. – Dave C Sep 23 '14 at 20:19
  • @DaveC and how can I verify this behaviour: my activity should start loading something from internet immediatly after resume? – netimen Sep 24 '14 at 10:00
  • 1
    Then you can verify that the content is actually loaded. For example if there's some text you expect to see after loading the data from the internet, your test method can call Assert.assertTrue(solo.waitForText("Text loaded from internet")); – Dave C Sep 24 '14 at 15:25

0 Answers0