简体   繁体   English

gradle espresso - 空的测试套件

[英]gradle espresso - Empty test suite

trying to run espresso integration-tests with gradle/Android-Studio - but no test is found: 尝试使用gradle / Android-Studio运行espresso集成测试 - 但没有找到测试:

package net.espresso_test;

import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.SmallTest;

@SmallTest
public class AddTest extends ActivityInstrumentationTestCase2<MainActivity> {

    public AddTest() {
        super(MainActivity.class);
    }

    public AddTest(Class<MainActivity> activityClass) {
        super(activityClass);
    }

    @Override
    public void setUp() throws Exception {
        super.setUp();
        // Espresso will not launch our activity for us, we must launch it via getActivity().
        getActivity();
    }

    @SuppressWarnings("unchecked")
    @SmallTest
    public void testAddItem() {
        fail();
    }

}

this is the build.gradle: 这是build.gradle:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
    maven {
        url project.hasProperty('ligisMavenUrl') ? ligisMavenUrl : "https://raw.github.com/ligi/ligis-mvn-repo/master";
    }
}

android {
    compileSdkVersion 19
    buildToolsVersion "19"

    defaultConfig {
        minSdkVersion 11
        targetSdkVersion 19
        testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
    }
}

dependencies {
    compile files('libs/socialauth-android-3.0.jar')
    compile files('libs/volley.jar')

    instrumentTestCompile files('libs/espresso-1.0-SNAPSHOT-bundled.jar')
    instrumentTestCompile 'com.google.guava:guava:11.0.2'

    compile 'org.ligi:AXT:0.21'

    compile 'com.android.support:appcompat-v7:18.0.0'
    compile 'com.android.support:support-v4:18.0.0'
    compile 'com.google.android.gms:play-services:3.2.25'
    compile 'com.squareup.dagger:dagger:1.1.0'
    compile 'com.squareup.dagger:dagger-compiler:1.1.0'
    compile 'com.jakewharton:butterknife:3.0.0'
}

have also tried a lot of other repos from github - all have the same problem - here is a hint that it could have to do something with guava ( which I do not use in this project ) - but no solution yet: 还尝试了很多来自github的其他repos - 都有同样的问题 - 这里有一个提示,它可能需要用番石榴做一些事情(我不在这个项目中使用) - 但还没有解决方案:

https://groups.google.com/d/msgid/android-test-kit-discuss/0e8bf175-498f-438e-b883-35b76bcede8d%40googlegroups.com https://groups.google.com/d/msgid/android-test-kit-discuss/0e8bf175-498f-438e-b883-35b76bcede8d%40googlegroups.com

really stuck here - would love to get any hint or ideally a link to a repo where it is working .. 真的卡在这里 - 希望得到任何暗示或理想的链接到它正在工作的回购..

I think you'll find that guava is a dependency for Espresso. 我想你会发现番石榴是Espresso的依赖品。

https://code.google.com/p/android-test-kit/source/browse/#git%2Fbin%2Fespresso-dependencies%253Fstate%253Dclosed https://code.google.com/p/android-test-kit/source/browse/#git%2Fbin%2Fespresso-dependencies%253Fstate%253Dclosed

You are using both the bundled espresso jar and a guava import which look like they contradict each other. 您正在使用捆绑的浓缩咖啡罐和番石榴进口,看起来它们互相矛盾。

instrumentTestCompile files('libs/espresso-1.0-SNAPSHOT-bundled.jar')
instrumentTestCompile 'com.google.guava:guava:11.0.2'

The bundled version of espresso comes with guava 14.0.1. 捆绑式浓缩咖啡配有番石榴14.0.1。

Remove the surplus guava jar you have in the gradle test dependencies. 删除gradle测试依赖项中的多余番石榴罐。

If this doesn't work can you also post the relevant section of you test manifest. 如果这不起作用,您还可以发布测试清单的相关部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM