Tôi nhận được cảnh báo lạ Method annotated with @Test inside class extending junit3 testcase
khi sử dụng lớp ActivityInstrumentationTestCase2
mới được giao bằng Espresso 2.0.Espresso 2.0 - Phương pháp được chú thích bằng @Test bên trong lớp mở rộng junit3 testcase
Lớp học của tôi trông giống như một trong đó Google cung cấp như một ví dụ:
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();
}
}
Tôi đã thêm tất cả mọi thứ cần thiết cho 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'
}
Có cách nào để nhận được cảnh báo này đi?
bạn có đang sử dụng các hướng dẫn này https://code.google.com/p/android-test-kit/wiki/EspressoSetupInstructions – helleye
Yep Tôi đã sử dụng chúng – Niklas
Vì vậy, trong bản dựng của bạn. bạn cũng có '// phụ thuộc của ứng dụng, bao gồm thử nghiệm biên dịch 'com.android.support:support-annotations:21.0.3' ' – helleye