@RunWith (AndroidJUnit4.class), , setUp(), @Gallal @Dariusz Gadomski, NullPointerExceptions.
It turns out that I forgot to include the annotation @Beforein my setup method, so jUnit4 did not run it, whereas before using jUnit3-based tool tests, it was run. Since I implemented the toolkit injection in setUp (), it was never entered, although the code looked as if it was entering it.
So instead
@Override
protected void setUp() throws Exception {
...
Be sure to use
@Before
public void setUp() throws Exception {
super.setUp();
injectInstrumentation(InstrumentationRegistry.getInstrumentation());
}
instead.
source
share