Question

trying to run espresso integration-tests with gradle/Android-Studio - but no test is found:

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:

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:

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 ..

Was it helpful?

Solution

I think you'll find that guava is a dependency for Espresso.

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.

Remove the surplus guava jar you have in the gradle test dependencies.

If this doesn't work can you also post the relevant section of you test manifest.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top