java testcase类_java – Espresso 2.0 – 在扩展junit3 testcase的类中使用@Test注释的方法...

当使用Espresso 2.0附带的新ActivityInstrumentationTestCase2类时,我得到了一个奇怪的警告方法,使用@Test内部类扩展junit3 testcase.

我的课程看起来就像谷歌提供的那样:

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 {

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();

}

}

我已经为build.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'

}

有没有办法让这个警告消失?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值