????????????????????????????????
?????lovexiaov ???????[ 2016/5/27 10:35:27 ] ??????????????? ???????
???????????????RobolectricGradleTestRunner????????
???????????ж???? application ??? Robolectric ?????????
public class IntegrationRobolectricTestRunner extends RobolectricGradleTestRunner {
// This value should be changed as soon as Robolectric will support newer api.
private static final int SDK_EMULATE_LEVEL = 21;
public IntegrationRobolectricTestRunner(@NonNull Class<?> clazz) throws Exception {
super(clazz);
}
@Override
public Config getConfig(@NonNull Method method) {
final Config defaultConfig = super.getConfig(method);
return new Config.Implementation(
new int[]{SDK_EMULATE_LEVEL}??
defaultConfig.manifest()??
defaultConfig.qualifiers()??
defaultConfig.packageName()??
defaultConfig.resourceDir()??
defaultConfig.assetDir()??
defaultConfig.shadows()??
MyIntegrationTestApp.class?? // Here is the trick?? we change application class to one with mocks.
defaultConfig.libraries()??
defaultConfig.constants() == Void.class ? BuildConfig.class : defaultConfig.constants()
);
}
}
????????? Instrumentation ????????? Dagger 2 ????????????
????Google ?????????????? flavors?????????????????????? flavors ????????????????????????????????? Gradle ???????????????????????????????????? flavors??
????????·???? Roboletric ????????——??????Application???????????????????? Instrumentation ?????
?????????????????????????? Instrumentation ???????????????????????build.gradle?С?
public class CustomInstrumentationTestRunner extends AndroidJUnitRunner {
@Override
@NonNull
public Application newApplication(@NonNull ClassLoader cl??
@NonNull String className??
@NonNull Context context)
throws InstantiationException??
IllegalAccessException??
ClassNotFoundException {
return Instrumentation.newApplication(CustomApp.class?? context);
}
}
??????????????build.gradle?У?
android {
defaultConfig {
testInstrumentationRunner 'a.b.c.CustomInstrumentationTestRunner'
}
}
??????????????????????????μ? #qualitymatters app?У?????????????????????????????????????????????????????? ???????????????????????????????????????????????????????????????????????? flavors??
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
iOS???????mocha??chai??sinon??istanbul???????????????????????????????????????д?????Java????????7??????Android?????????Robolectric3.0????(?)???Kiwi?????????????????????????????????Python?????????????????????????????????????Controller????????д?????????10???????????????????Angular????????????Component??Directive??Pipe ???ServiceAndroid????????????????????????????????--Mockito??????iOS UnitTest???????Vue?????????????????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????