在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):JakeWharton/gradle-android-test-plugin开源软件地址(OpenSource Url):https://github.com/JakeWharton/gradle-android-test-plugin开源编程语言(OpenSource Language):Java 50.7%开源软件介绍(OpenSource Introduction):DEPRECATEDThis plugin is deprecated and is no longer being developed. The Android tools team has committed to unit test support in v1.1 and will be improving it in subsequent releases. Gradle Android Unit Testing PluginA Gradle plugin which enables good 'ol fashioned unit tests for Android builds. UsageAdd the plugin to your classpath 'com.squareup.gradle:gradle-android-test-plugin:0.9.+' Apply the apply plugin: 'android-test' Add test-only dependencies using the testCompile 'junit:junit:4.10'
testCompile 'org.robolectric:robolectric:2.1.+'
testCompile 'com.squareup:fest-android:1.0.+' Write your tests in RobolectricThe Android framework is not built with unit testing in mind. As such, the canonical framework to facilitate unit testing on the JVM is Robolectric. Version 2.3 of Robolectric will support this plugin out of the box (see here). Until then, you can use the following test runner: import org.junit.runners.model.InitializationError;
import org.robolectric.AndroidManifest;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.res.Fs;
public class RobolectricGradleTestRunner extends RobolectricTestRunner {
public RobolectricGradleTestRunner(Class<?> testClass) throws InitializationError {
super(testClass);
}
@Override protected AndroidManifest getAppManifest(Config config) {
String manifestProperty = System.getProperty("android.manifest");
if (config.manifest().equals(Config.DEFAULT) && manifestProperty != null) {
String resProperty = System.getProperty("android.resources");
String assetsProperty = System.getProperty("android.assets");
return new AndroidManifest(Fs.fileFromPath(manifestProperty), Fs.fileFromPath(resProperty),
Fs.fileFromPath(assetsProperty));
}
return super.getAppManifest(config);
}
} Just annotate your test classes with Plugin DevelopmentThe
License
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论