使用发布版本类型运行espresso测试时未解析的引用

时间:2017-02-15 15:31:50

标签: android android-espresso

我正在尝试使用版本构建类型运行espresso测试以实现qa目的,并在此答案Android Studio Instrumentation testing build variant上建议配置。使用调试版本类型成功运行测试,但是在发布类型中我得到以下错误

Warning:there were 118 unresolved references to classes or interfaces.
Warning:there were 8 instances of library classes depending on program classes.
Warning:there were 3 unresolved references to program class members.
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.

Error:Execution failed for task ':Offrie:transformClassesAndResourcesWithProguardForQaReleaseAndroidTest'.
> Job failed, see logs for details

以下是espresso测试

@MediumTest
@RunWith(AndroidJUnit4.class)
public class MainActivityInstrumentationTest {

    @Rule
    public ActivityTestRule<MainActivity> activityRule
            = new ActivityTestRule<>(
            MainActivity.class,
            true,
            false);

    @Test
    public void shouldShowNotificationContentWhenActivityIsDestroyed() {
        final String NOTIFICATION_TITLE = "Título";
        final String NOTIFICATION_CONTENT = "Texto";

        Intent intent = buildNotificationIntent(NOTIFICATION_TITLE, NOTIFICATION_CONTENT);

        activityRule.launchActivity(intent);

        onView(withId(R.id.notification_title)).check(matches(allOf(withText(NOTIFICATION_TITLE), isDisplayed())));
        onView(withId(R.id.notification_content)).check(matches(allOf(withText(NOTIFICATION_CONTENT), isDisplayed())));
    }

    @NonNull
    private Intent buildNotificationIntent(String NOTIFICATION_TITLE, String NOTIFICATION_CONTENT) {
        Intent intent = new Intent();

        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        intent.putExtra(NotificationsUtils.NOTIFICATION_TITLE_PARAMETER, NOTIFICATION_TITLE);
        intent.putExtra(NotificationsUtils.NOTIFICATION_TEXT_PARAMETER, NOTIFICATION_CONTENT);
        return intent;
    }

这些是输出的两个屏幕截图

enter image description here

enter image description here

如何解决此依赖性问题?

0 个答案:

没有答案