【发布时间】:2017-07-03 12:49:04
【问题描述】:
这就是我的 ApplicationTest 类的样子:
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing
Fundamentals</a>
*/
@RunWith(AndroidJUnit4.class)
@LargeTest
public class ApplicationTest {
@Rule
public ActivityTestRule mActivityRule =
new ActivityTestRule(VMBaseActivity.class,
false /* Initial touch mode */, false /* launch activity */) {
@Override
protected void afterActivityLaunched() {
// Enable JavaScript.
Log.i("","activity has been started");
}
};
@Test
public void enterPin() {
// Type text and then press the button.
onView(withId(R.id.button0)).perform(click());
onView(withId(R.id.button0)).perform(click());
onView(withId(R.id.button0)).perform(click());
onView(withId(R.id.button0)).perform(click());
}
}
我的 build.gradle 中有这个
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
但是当我运行时,我得到了这个错误:
Client not ready yet..
Started running tests
junit.framework.AssertionFailedError: No tests found in com.vidyo.vidyomod.ApplicationTest
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1893)
Tests ran to completion.
为什么应用找不到我的测试?
【问题讨论】:
标签: android unit-testing testing junit4 android-espresso