I've seen similar questions but I still can't fix it, so sorry for possible duplication.
I wrote some Roboletric tests for my activity. I can pass them all only if I directly run the whole class. But if I run the whole test pack - they fails.
@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class)
public class MainActivityTest {
private MainActivity activity;
@Before
public void setUp() throws Exception {
activity = Robolectric.buildActivity(MainActivity.class)
.create()
.resume()
.get();
}
@Test
public void shouldNotBeNull() throws Exception {
assertNotNull(activity);
}
@Test
public void shouldHaveCorrectAppName() throws Exception {
String appName = activity.getResources().getString(R.string.app_name);
assertThat(appName, equalTo("KeylessEntryFSM"));
}
Some examples. I also use Mockito tests, they works correct. I must run them all from a console.
Aucun commentaire:
Enregistrer un commentaire