I am trying to run tests using espresso 2.2.1 in Android Studio 1.5.1. When I run LoginActivityTest, I get this error: "android.content.res.Resources $ NotFoundException", caused when LoginActivity calls MyService.java and MyService needs whole resources (i.e. Rinteger.number_of_days). These resources are defined in the R.integer.xml file in the gradle module (version 1.5.0).
Project Structure:
RootFolder/ ├----projectA/ │ ├----build.gradle │ ├----settings.gradle │ └----src/androidTest/java/.../LoginActivityTest │ └----src/main/java/.../LoginActivity │ └----Module/ ├----krill/ │ └----build.gradle │ ├----settings.gradle │ └----src/main/ | └----java/service/MyService.java | └----res/value/integers.xml │ └----otherModule/ └----build.gradle
My test class:
@RunWith(AndroidJUnit4.class) @LargeTest public class LoginActivityTest extends ActivityInstrumentationTestCase2<LoginActivity >{ @Rule public ActivityTestRule<LoginActivity> mActivityRule = new ActivityTestRule(LoginActivity.class); public LoginActivityTest() { super(LoginActivity.class); } @Test public void testConfigDialog() { onView(withId(R.layout.login_custom_view)); onView(withId(R.id.id_username)).perform(clearText()); onView(withId(R.id.id_password)).perform(clearText()); } }
stacktrace error:
Running tests Test running started android.content.res.Resources$NotFoundException: Resource ID
How can I fix this problem?
source share