简体   繁体   English

适用于Android的参数化仪器测试

[英]Parameterized Instrumented Tests for Android

The answer to AndroidJUnit4 and Parameterized tests links to a Google example for using @RunWith(Parameterized.class) . AndroidJUnit4和参数化测试的答案链接到使用@RunWith(Parameterized.class)的Google示例。 However, this is a simple unit test. 但是,这是一个简单的单元测试。 How do I run parameterized instrumented tests? 如何运行参数化检测测试?

Actually, you should put your test with @RunWith(Parameterized.class) runner in the androidTest folder instead of test folder. 实际上,你应该在androidTest文件夹而不是test文件夹中使用@RunWith(Parameterized.class) androidTest进行test That test will be run on the emulator and you will be able to unit test classes with android dependencies, like android.graphics.Rect etc. Of course, don't forget 该测试将在模拟器上运行,您将能够使用android依赖项单元测试类,如android.graphics.Rect等。当然,不要忘记

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

}

and dependencies : 和依赖:

dependencies {
    androidTestCompile 'com.android.support.test:runner:+'
    androidTestCompile 'com.android.support:support-annotations:+'
}

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

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