为了账号安全,请及时绑定邮箱和手机立即绑定

启用Java 8时,Android Studio Ui测试给出错误

启用Java 8时,Android Studio Ui测试给出错误

神不在的星期二 2021-04-06 13:09:51
我在Android Studio 3.2.1和Android Studio 3.4上尝试过,如果我在gradle文件中启用Java 8并运行espresso测试,则会收到以下错误消息:java.lang.RuntimeExceptionCause: java.lang.RuntimeException经过多次试验,我发现从gradle文件中删除Java8支持可解决此问题。但是Java 8对于我的项目很重要。您有更好的解决方案吗?这是我的代码:import static androidx.test.espresso.action.ViewActions.click;import static androidx.test.espresso.assertion.ViewAssertions.matches;import static androidx.test.espresso.matcher.ViewMatchers.withId;import static androidx.test.espresso.matcher.ViewMatchers.withText;import androidx.test.espresso.Espresso;import androidx.test.ext.junit.runners.AndroidJUnit4;import androidx.test.filters.LargeTest;import androidx.test.rule.ActivityTestRule;import com.dubizzle.workshopsample.R;import org.junit.Rule;import org.junit.Test;import org.junit.runner.RunWith;@RunWith(AndroidJUnit4.class)@LargeTestpublic class MainActivityUiTest {  @Rule  public ActivityTestRule<MainActivity> mActivityRule      = new ActivityTestRule<>(MainActivity.class);  @Test  public void testShareButtonClickedUi() {    Espresso.onView(withId(R.id.txtStatus))        .check(matches(withText("Hello World!")));    Espresso.onView(withId(R.id.btnShare)).perform(click());    Espresso.onView(withId(R.id.txtStatus))        .check(matches(withText("onShareButtonClicked")));  }}
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 144 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信