问题
I am using espresso and ui automation for test cases and generating report by running gradlew.bat :app:createDebugCoverageReport in command prompt.
My Problem:-
I am having LoginTest activity which contains 4 or 5 methods in it.Methods are named in sorting order using @FixMethodOrder(MethodSorters.NAME_ASCENDING).When i run the command gradlew.bat :app:createDebugCoverageReport in command prompt it runs one method only,after completion stop the app.For example :- It runs aa_doLogin() only.Does not run cc_secondmethod and bb_firstmethod.
My Code:-
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class LoginTest{
@Before
setup(){
}
@Test
aa_doLogin(){
bb_firstmethod()
}
@Test
bb_firstmethod(){
cc_secondmethod
}
@Test
cc_secondmethod(){
}
}
Error :-
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)
来源:https://stackoverflow.com/questions/43136553/complete-logintest-does-not-run-in-android-using-espresso