api10:connectedAndroidTest + espresso:未找到测试

时间:2016-06-24 16:14:22

标签: android android-gradle android-espresso

我想通过命令行自动使用espresso。我已经编写了一些从android studio运行良好的测试,他们也可以使用模拟器api 16级和23级。在api 10级我收到此错误信息(仅通过gradle connectedAndroidTest运行):

com.android.builder.testing.ConnectedDevice > No tests found.
[Nexus_4_API_10(AVD) - 2.3.7] [31mFAILED [0m
No tests found.
This usually means that your test classes are not in the form that your test runner expects
(e.g. don't inherit from TestCase or lack @Test annotations).
:app:connectedSourceDebugAndroidTest FAILED

(Source = flavor,Debug = build type)

我遵循了这个指南: https://developer.android.com/training/testing/ui-testing/espresso-testing.html

@RunWith(AndroidJUnit4.class)
public class LocaleTest{

@Rule
public ActivityTestRule<MainActivity> activityTestRule =
        new ActivityTestRule<>(MainActivity.class);

@Test
public void testSomethings(){
    //some code
}
}

我的build.gradle个依赖关系:

dependencies {
compile ('com.android.support:support-annotations:23.0.1')
androidTestCompile ('com.android.support.test:runner:0.5'){
    exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile ('com.android.support.test:rules:0.5'){
    exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile ('com.android.support.test.espresso:espresso-core:2.2.2'){
    exclude group: 'com.android.support', module: 'support-annotations'
}
compile 'com.android.support:appcompat-v7:23.0.1'
}

默认配置我添加了

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

先谢谢,我的想法已经不多了。

编辑(2016年6月27日): LogCat输出

06-27 13:02:30.768 4485-4485/? D/dalvikvm: DexOpt: 'Ljunit/extensions/ActiveTestSuite$1;' has an earlier definition; blocking out
06-27 13:02:30.768 4485-4485/? D/dalvikvm: DexOpt: 'Ljunit/framework/Assert;' has an earlier definition; blocking out
06-27 13:02:30.768 4485-4485/? D/dalvikvm: DexOpt: 'Ljunit/framework/AssertionFailedError;' has an earlier definition; blocking out
06-27 13:02:30.768 4485-4485/? D/dalvikvm: DexOpt: 'Ljunit/framework/Protectable;' has an earlier definition; blocking out
06-27 13:02:30.768 4485-4485/? D/dalvikvm: DexOpt: 'Ljunit/framework/Test;' has an earlier definition; blocking out
06-27 13:02:30.768 4485-4485/? D/dalvikvm: DexOpt: 'Ljunit/framework/TestFailure;' has an earlier definition; blocking out
06-27 13:02:30.768 4485-4485/? D/dalvikvm: DexOpt: 'Ljunit/framework/TestListener;' has an earlier definition; blocking out
06-27 13:02:30.768 4485-4485/? D/dalvikvm: DexOpt: 'Ljunit/framework/TestResult;' has an earlier definition; blocking out
06-27 13:02:30.772 4485-4485/? D/dalvikvm: DexOpt: 'Ljunit/extensions/TestDecorator;' has an earlier definition; blocking out
06-27 13:02:30.772 4485-4485/? D/dalvikvm: DexOpt: 'Ljunit/extensions/TestSetup$1;' has an earlier definition; blocking out
06-27 13:02:30.777 4485-4485/? D/dalvikvm: DexOpt: 'Ljunit/framework/ComparisonFailure;' has an earlier definition; blocking out
06-27 13:02:30.777 4485-4485/? D/dalvikvm: DexOpt: 'Ljunit/framework/TestCase;' has an earlier definition; blocking out
06-27 13:02:30.777 4485-4485/? D/dalvikvm: DexOpt: 'Ljunit/framework/TestResult$1;' has an earlier definition; blocking out
06-27 13:02:30.777 4485-4485/? D/dalvikvm: DexOpt: 'Ljunit/framework/TestSuite;' has an earlier definition; blocking out
06-27 13:02:30.784 4485-4485/? D/dalvikvm: DexOpt: 'Ljunit/extensions/ActiveTestSuite;' has an earlier definition; blocking out
06-27 13:02:30.784 4485-4485/? D/dalvikvm: DexOpt: 'Ljunit/extensions/RepeatedTest;' has an earlier definition; blocking out
06-27 13:02:30.784 4485-4485/? D/dalvikvm: DexOpt: 'Ljunit/extensions/TestSetup;' has an earlier definition; blocking out
06-27 13:02:30.784 4485-4485/? D/dalvikvm: DexOpt: 'Ljunit/framework/TestSuite$1;' has an earlier definition; blocking out
06-27 13:02:30.832 4485-4485/? I/dalvikvm: DexOpt: not resolving ambiguous class 'Ljunit/framework/AssertionFailedError;'
06-27 13:02:30.832 4485-4485/? I/dalvikvm: DexOpt: not resolving ambiguous class 'Ljunit/framework/Test;'
06-27 13:02:30.832 4485-4485/? I/dalvikvm: DexOpt: not resolving ambiguous class 'Ljunit/framework/Test;'
06-27 13:02:30.836 4485-4485/? D/dalvikvm: DexOpt: not verifying 'Ljunit/extensions/ActiveTestSuite$1;': multiple definitions
06-27 13:02:30.836 4485-4485/? D/dalvikvm: DexOpt: not verifying 'Ljunit/framework/Assert;': multiple definitions
06-27 13:02:30.836 4485-4485/? D/dalvikvm: DexOpt: not verifying 'Ljunit/framework/AssertionFailedError;': multiple definitions
06-27 13:02:30.836 4485-4485/? I/dalvikvm: DexOpt: not resolving ambiguous class 'Ljunit/framework/Assert;'
06-27 13:02:30.836 4485-4485/? I/dalvikvm: DexOpt: not resolving ambiguous class 'Ljunit/framework/Test;'
06-27 13:02:30.836 4485-4485/? D/dalvikvm: DexOpt: not verifying 'Ljunit/framework/Protectable;': multiple definitions
06-27 13:02:30.836 4485-4485/? D/dalvikvm: DexOpt: not verifying 'Ljunit/framework/Test;': multiple definitions
06-27 13:02:30.836 4485-4485/? D/dalvikvm: DexOpt: not verifying 'Ljunit/framework/TestFailure;': multiple definitions
06-27 13:02:30.836 4485-4485/? D/dalvikvm: DexOpt: not verifying 'Ljunit/framework/TestListener;': multiple definitions
06-27 13:02:30.836 4485-4485/? D/dalvikvm: DexOpt: not verifying 'Ljunit/framework/TestResult;': multiple definitions
06-27 13:02:30.836 4485-4485/? I/dalvikvm: DexOpt: not resolving ambiguous class 'Ljunit/framework/TestSuite;'
06-27 13:02:30.844 4485-4485/? I/dalvikvm: DexOpt: not resolving ambiguous class 'Ljunit/framework/AssertionFailedError;'
06-27 13:02:30.844 4485-4485/? I/dalvikvm: DexOpt: not resolving ambiguous class 'Ljunit/framework/AssertionFailedError;'
06-27 13:02:30.844 4485-4485/? I/dalvikvm: DexOpt: not resolving ambiguous class 'Ljunit/framework/AssertionFailedError;'
06-27 13:02:30.844 4485-4485/? I/dalvikvm: DexOpt: not resolving ambiguous class 'Ljunit/framework/AssertionFailedError;'
06-27 13:02:30.864 4485-4485/? I/dalvikvm: DexOpt: not resolving ambiguous class 'Ljunit/framework/TestResult;'
06-27 13:02:30.868 4485-4485/? I/dalvikvm: DexOpt: not resolving ambiguous class 'Ljunit/framework/TestCase;'
06-27 13:02:30.868 4485-4485/? I/dalvikvm: DexOpt: not resolving ambiguous class 'Ljunit/framework/Test;'
06-27 13:02:30.868 4485-4485/? D/dalvikvm: DexOpt: not verifying 'Ljunit/extensions/TestDecorator;': multiple definitions
06-27 13:02:30.868 4485-4485/? D/dalvikvm: DexOpt: not verifying 'Ljunit/extensions/TestSetup$1;': multiple definitions
06-27 13:02:30.868 4485-4485/? D/dalvikvm: DexOpt: not verifying 'Ljunit/framework/ComparisonFailure;': multiple definitions
06-27 13:02:30.868 4485-4485/? I/dalvikvm: DexOpt: not resolving ambiguous class 'Ljunit/framework/TestResult;'
06-27 13:02:30.872 4485-4485/? D/dalvikvm: DexOpt: not verifying 'Ljunit/framework/TestCase;': multiple definitions
06-27 13:02:30.872 4485-4485/? D/dalvikvm: DexOpt: not verifying 'Ljunit/framework/TestResult$1;': multiple definitions
06-27 13:02:30.872 4485-4485/? D/dalvikvm: DexOpt: not verifying 'Ljunit/framework/TestSuite;': multiple definitions
06-27 13:02:30.872 4485-4485/? I/dalvikvm: DexOpt: not resolving ambiguous class 'Ljunit/framework/TestSuite;'
06-27 13:02:30.872 4485-4485/? I/dalvikvm: DexOpt: not resolving ambiguous class 'Ljunit/framework/TestFailure;'
06-27 13:02:30.872 4485-4485/? I/dalvikvm: DexOpt: not resolving ambiguous class 'Ljunit/framework/TestCase;'
06-27 13:02:30.872 4485-4485/? I/dalvikvm: DexOpt: not resolving ambiguous class 'Ljunit/framework/TestCase;'
06-27 13:02:30.888 4485-4485/? I/dalvikvm: DexOpt: not resolving ambiguous class 'Ljunit/framework/TestCase;'
06-27 13:02:30.888 4485-4485/? I/dalvikvm: DexOpt: not resolving ambiguous class 'Ljunit/framework/TestSuite;'
06-27 13:02:30.888 4485-4485/? I/dalvikvm: DexOpt: not resolving ambiguous class 'Ljunit/framework/Protectable;'
06-27 13:02:30.888 4485-4485/? I/dalvikvm: DexOpt: not resolving ambiguous class 'Ljunit/framework/TestSuite;'
06-27 13:02:30.888 4485-4485/? I/dalvikvm: DexOpt: not resolving ambiguous class 'Ljunit/framework/TestSuite;'
06-27 13:02:30.888 4485-4485/? I/dalvikvm: DexOpt: not resolving ambiguous class 'Ljunit/framework/TestSuite;'
06-27 13:02:30.888 4485-4485/? D/dalvikvm: DexOpt: not verifying 'Ljunit/extensions/ActiveTestSuite;': multiple definitions
06-27 13:02:30.888 4485-4485/? D/dalvikvm: DexOpt: not verifying 'Ljunit/extensions/RepeatedTest;': multiple definitions
06-27 13:02:30.888 4485-4485/? D/dalvikvm: DexOpt: not verifying 'Ljunit/extensions/TestSetup;': multiple definitions
06-27 13:02:30.888 4485-4485/? D/dalvikvm: DexOpt: not verifying 'Ljunit/framework/TestSuite$1;': multiple definitions
06-27 13:02:30.888 4485-4485/? I/dalvikvm: DexOpt: not resolving ambiguous class 'Ljunit/framework/TestResult;'
06-27 13:02:30.888 4485-4485/? I/dalvikvm: DexOpt: not resolving ambiguous class 'Ljunit/framework/TestSuite;'
06-27 13:02:30.896 4485-4485/? I/dalvikvm: DexOpt: not resolving ambiguous class 'Ljunit/framework/TestSuite;'
06-27 13:02:30.896 4485-4485/? I/dalvikvm: DexOpt: not resolving ambiguous class 'Ljunit/framework/Test;'
06-27 13:02:30.904 4485-4485/? I/dalvikvm: DexOpt: not resolving ambiguous class 'Ljunit/framework/TestSuite;'

0 个答案:

没有答案