Answer the question
In order to leave comments, you need to log in
Why doesn't Robolectric call onCreate()?
I'm trying to write tests using Robolectric, but the trouble is that it does not call onCreate () and other life methods of activation, or it just calls it is not clear how. For when I further use variables / objects that must be initialized, then my tests crash with NPE, because during the test there was an attempt to access a NULL object. Judging from what I understood, onCreate () was not called correctly. Tried to go through the lifecycle in the following ways:
1)
MainActivity activity = Robolectric.buildActivity(MainActivity.class).create().start().resume().get();
MainActivity activity = Robolectric.setupActivity(MainActivity.class)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question