0
Hello, I’d like to know how I use robolectric in my projects on Android Studio. I have tried several tutorials, but none was of great help and the documentation of it is not very clear.
0
Hello, I’d like to know how I use robolectric in my projects on Android Studio. I have tried several tutorials, but none was of great help and the documentation of it is not very clear.
1
First, include the jar in your project dependencies.
Then use the annotation RunWith
(Available in Junit4):
Example:
@RunWith(RobolectricTestRunner.class)
public class TesteRobolectric {
@Test
public void aplicacao() throws Exception {
String appName = new RobolectricUso().getResources().getString(R.string.app_name);
assertThat(appName, equalTo("RobolectricUso"));
}
}
Recommended is to use Maven with plugin.
More uses see here.
Browser other questions tagged android android-studio testing unit-testing
You are not signed in. Login or sign up in order to post.