I have an ActivityInstrumentationTestCase2 (which is a subclass of InstrumentationTestCase). When running my testcases, I need to launch my activities using a custom TestApplication object, since this TestApplication objects has some configuration necessary for my tests.
However, I don’t see a way to customize my ActivityInstrumentationTestCase2 testcases to use the test Application object. Is there a way to do so?
I don’t know if there’s a better way, but I was able to accomplish this by using a custom TestRunner.
I also needed to modify my test project’s AndroidManifest.xml to specify the new runner:
And I had to modify my IDE to use the specified test runner as well. If you’re running from the command line, you’ll need to do something like the following instead: