完整的LoginTest不会在使用浓缩咖啡的android系统中运行

完整的LoginTest不会在使用浓缩咖啡的android系统中运行,android,android-gradle-plugin,ui-automation,android-espresso,Android,Android Gradle Plugin,Ui Automation,Android Espresso,我正在对测试用例使用espresso和ui自动化,并通过在命令提示符下运行gradlew.bat:app:createDebugCoverageReport生成报告 我的问题:- @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class LoginTest{ @Before setup(){ } @Test aa_doLogin(){ bb_firstmethod() } @Test bb_firstmethod(){ c

我正在对测试用例使用espresso和ui自动化,并通过在命令提示符下运行gradlew.bat:app:createDebugCoverageReport生成报告

我的问题:-

@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class LoginTest{
@Before
setup(){
}

@Test 
aa_doLogin(){
   bb_firstmethod()
}
@Test
bb_firstmethod(){
  cc_secondmethod
}
@Test
cc_secondmethod(){
}
}
我正在进行LoginTest活动,其中包含4或5个方法。方法是使用@FixMethodOrder(MethodSorters.NAME\u升序)按排序顺序命名的。当我在命令提示符下运行命令gradlew.bat:app:createDebugCoverageReport时,它只运行一个方法,完成后停止应用程序。例如:-它只运行aa_doLogin()。不运行cc_secondmethod和bb_firstmethod。

我的代码:-

@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class LoginTest{
@Before
setup(){
}

@Test 
aa_doLogin(){
   bb_firstmethod()
}
@Test
bb_firstmethod(){
  cc_secondmethod
}
@Test
cc_secondmethod(){
}
}
错误:-

java.lang.RuntimeException: No activities found. Did you forget to launch the activity by calling getActivity() or startActivitySync or similar?
at android.support.test.espresso.base.RootViewPicker.waitForAtLeastOneActivityToBeResumed(RootViewPicker.java:189)
at android.support.test.espresso.base.RootViewPicker.findRoot(RootViewPicker.java:134)
at android.support.test.espresso.base.RootViewPicker.get(RootViewPicker.java:80)
at android.support.test.espresso.ViewInteractionModule.provideRootView(ViewInteractionModule.java:69)
at android.support.test.espresso.ViewInteractionModule_ProvideRootViewFactory.get(ViewInteractionModule_ProvideRootViewFactory.java:23)
at android.support.test.espresso.ViewInteractionModule_ProvideRootViewFactory.get(ViewInteractionModule_ProvideRootViewFactory.java:9)
at android.support.test.espresso.base.ViewFinderImpl.getView(ViewFinderImpl.java:68)
at android.support.test.espresso.ViewInteraction$1.run(ViewInteraction.java:120)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)

@希夫拉姆:这是单元测试还是浓缩咖啡测试?如果没有@RunWith或@Rule组件,那么发布的代码似乎缺少基本的浓缩咖啡要求。请参阅此答案以获取添加内容的示例:我使用了@Rule,但没有使用RuleWith,但使用RuleWith时,报告无法正确生成Paul@Shivram你能确认这是一个单元测试还是一个用户界面(浓缩咖啡)吗测试?浓缩咖啡测试。你能告诉我为什么会出现这个错误吗?我相信这是因为你没有定义@Rule的ActivityTestRule。这就是为什么我让您参考上面的示例链接。没有完整的代码示例,我们无法确定。