0

I'm also using Robotium testing framework. My application does some setup work that is necessary to be done first in order for the tests to work.

I know that ActivityInstrumentationTestCase2#getActivity is called, the activity is started if it hasn't already. But I need something setup first by the app or the code stops in error.

kaneda
  • 5,981
  • 8
  • 48
  • 73

3 Answers3

2

When you are talking about pre-activity setup, are you doing it in you Application class.

It's not really clear, but if you have a Application class defined in your manifest, it will run before any activities.

However, if you do long-running stuff here it may block, and if you have threads you may have a race condition with your activity.

HaMMeReD
  • 2,440
  • 22
  • 29
  • I don't have either. It's just database setup. – kaneda Sep 10 '12 at 19:40
  • You can initialize your Database in you Application class. Create one, initialize in onCreate() and it'll be created before you use it. It's a good place to store a reference to your database as well since it's the most appropriate place for a global db connection. – HaMMeReD Sep 11 '12 at 17:55
0

Answer is No. In android, testing is done before creating build

RajeshVijayakumar
  • 10,281
  • 11
  • 57
  • 84
  • I don't think you understand the question. Robotium runs on the emulator, against the real application. – HaMMeReD Sep 10 '12 at 19:20
0

You probably use

@Override public void setUp() throws Exception {
    super.setUp();
    solo = new Solo(getInstrumentation(), getActivity());
}

prior to any tests. You should be able to insert your activity-setup-code there.

serv-inc
  • 35,772
  • 9
  • 166
  • 188