I have simple Application class:
public class MainApplication extends Application {
public MainApplication() throws Exception {
throw new Exception();
}
}
and simple test:
public class SimpleTests extends AndroidTestCase {
public void testSum() {
assertEquals(4, 2 + 2);
}
}
why I get an Exception on my tests starting? How my test is related with the Application class?
Running tests
Test running startedTest running failed: Instrumentation run failed due to 'java.lang.Exception'
Empty test suite.
Android Studio v.1.5.1
UPDATE: my Application subclass of course is more complex and contains business logic in method "onCreate". I do not want to run this logic when I run my tests.
Applicationsubclass registered in your manifest (android:nameon the<application>element), an instance of thatApplicationsubclass will be created every time your app's process starts. "How my test is related with the Application class?" -- apparently, you are testing an Android app that is using thisApplicationclass as described in my previous paragraph. If you feel that this is not the case, perhaps you might post the relevant manifest and test code.Applicationsubclass so that it will work when being tested.