Espresso-2.0 - Methode annotiert mit @Test im inneren Klasse, die sich junit3 testcase

Bekam ich eine seltsame Warnung Method annotated with @Test inside class extending junit3 testcase wenn die neue ActivityInstrumentationTestCase2 Klasse geliefert mit Espresso 2.0.

Meiner Klasse sieht genauso aus wie die, die Google als Beispiel bereitgestellt:

import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.LargeTest;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import static android.support.test.espresso.matcher.ViewMatchers.assertThat;
import static org.hamcrest.Matchers.notNullValue;

@RunWith(AndroidJUnit4.class)
@LargeTest
public class MyCoolActivityTests extends ActivityInstrumentationTestCase2<MyCoolActivity> {

    private MyCoolActivity mActivity;

    public MyCoolActivityTests() {
        super(MyCoolActivity.class);
    }

    @Before
    public void setUp() throws Exception {
        super.setUp();
        injectInstrumentation(InstrumentationRegistry.getInstrumentation());
        mActivity = getActivity();
    }

    @Test
    public void checkPreconditions() {
        assertThat(mActivity, notNullValue());
        //Check that Instrumentation was correctly injected in setUp()
        assertThat(getInstrumentation(), notNullValue());
    }

    @After
    public void tearDown() throws Exception {
        super.tearDown();
    }
}

Ich habe alle nötigen Dinge auf die bauen.gradle:

android {
    defaultConfig {
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
}

dependencies {
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.0'
    androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
}

Gibt es eine Möglichkeit, diese Warnung Weg?

  • verwenden Sie diese Anweisungen, code.google.com/p/android-test-kit/wiki/...
  • Ja, ich habe Sie
  • Also in deinem build.gradle haben Sie auch // App's dependencies, including test compile 'com.android.support:support-annotations:21.0.3'
  • Yup ich vergaß zu hinzufügen zu der Frage, seit ich ausgezogen habe den nicht notwendigen Kram aus ihm heraus.
InformationsquelleAutor Niklas | 2014-12-22
Schreibe einen Kommentar