- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我在Android 1.1.0之前用过Robolectric,但更新后就不能用了。我用谷歌搜索并尝试了一些解决方案,但没有一个有效。这是我当前的设置:
项目.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'com.github.jcandksolutions.gradle:android-unit-test:2.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
应用程序.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "my_package_name"
minSdkVersion 9
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
apply plugin: 'android-unit-test'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:recyclerview-v7:21.0.3'
testCompile 'org.easytesting:fest:1.0.16'
testCompile 'junit:junit:4.10'
testCompile 'org.robolectric:robolectric:2.4'
testCompile 'com.squareup:fest-android:1.0.8'
}
当我尝试构建项目时,出现如下错误:
Error:(22) A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'android-unit-test']
> No such property: bootClasspath for class: com.android.build.gradle.AppPlugin
当然,我安装并删除了 android-unit-test 插件,然后又重新安装了它,但没有成功。
我们将不胜感激。
最佳答案
坏消息:从 Android 插件 1.1.0 开始,插件 com.github.jcandksolutions.gradle:android-unit-test:2.1.1
被弃用了。另见 https://github.com/JCAndKSolutions/android-unit-test#deprecation-notice
好消息:您不再需要 robolectric 插件。只需删除 apply plugin: 'android-unit-test'
一切都应该像以前一样工作。
这是一个示例项目设置 https://github.com/nenick/AndroidStudioAndRobolectric
关于Android studio 1.1.0 无法设置 Robolectric,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29714750/
有没有办法在使用 Robolectric 运行测试时修复系统时钟?我有一些代码取决于星期几。在 rspec 中,有 TimeCop gem 允许您为系统修复时间。 Robolectric 有等效项吗?
实际上,我需要获取 API 调用的响应,为此我需要 Context。 最佳答案 更新。 仅用于版本 1.x 和 2.x: Robolectric.application; 对于 3.x 版本: Run
我在使用 roboelectric 2.2 时遇到以下错误 java.lang.IncompatibleClassChangeError: class org.objectweb.asm.tree.C
我正在使用 Robolectric用于我的单元测试并更新了我的Robolectric从 1.2 到 2.2 的 jar 并试图弄清楚如何在这个新版本中绑定(bind)影子类。这是我之前在做的: Rob
将 LeakCanary (1.3) 添加到我的应用程序中: @Override public void onCreate() { super.onCreate(); Fabric.w
我按照官方教程将 robolectric 添加到我现有的 Android 应用程序中。但是当我尝试运行一个简单的测试时,我收到了一个错误: java.lang.RuntimeException: No
我正在为一个使用多 dex 的项目配置 Robolectric。我正在使用 Robolectric 3.0 RC3,它应该支持 Multidex 而不会抛出“Multi dex 安装失败”异常。 te
我是 Robolectric 的新手,请帮助我理解它,这些有什么区别 loginActivity = new LoginActivity();loginActivity = Robolectric.s
在 Android Studio 中同步我的 Gradle 项目时,出现以下错误: Error:Could not find any version that matches org.robolect
我正在尝试使用 Robolectric 设置测试以单击 this repository 中的菜单按钮.基本的 Robolectric 测试将运行,但我无法使用资源运行任何特定于项目的测试,因为它说它找
我在网上搜索了如何使用 android studio 配置 robolectric。 网上有很多资料,但没有一个适合我。每个人都有自己的使用android studio配置Robolectric的步骤
我正在使用 robolectric 来测试一项使用 Google Analytics 的 Activity 。不幸的是,每当我尝试启动 Activity 时,我都会遇到以下异常 android.dat
我按照列出的方式运行迁移 here 运行测试后,我收到带有内部堆栈跟踪的错误 java.lang.RuntimeException: java.lang.ClassNotFoundException:
我在运行测试时出现间歇性故障。 java.lang.NullPointerException at org.robolectric.res.ResBundle$Value.compareTo(
我曾经使用 Android 单元测试运行我的单元测试,但后来切换到使用 Robolectric 的 Java 单元测试。我注意到使用 SaxParser DefaultHandler 的不同之处。基本
我在测试 getView 时遇到错误。测试代码在测试用例期间调用 View.setImageResource(0) 以在异常发生时设置空图像。 我用 Eclipse 运行了测试 robolectric
使用 Robolectric.buildActivity().setup() 的 JUnit 测试在 AndroidX 和 Robolectric 4.3 下不一致地失败。通常在测试套件中,像这样的前
使用.withIntent()创建事件在Robolectric 2中不起作用吗?我正在做以下 activity = Robolectric.buildActivity(MyActivity.c
我知道 Robolectric 官方网站上说这个框架用于单元测试,但在所有示例 robolectric 上都用于测试 View ...例如:Robolectric 可用于检查 textview X 的
是否可以在自己的模块中设置 robolectric 并将其作为依赖项添加到我的项目中?我可以将它添加到我的项目模块中,但如果它在它自己的模块中,我更喜欢它。我创建了一个 javaLibrary 模块并
我是一名优秀的程序员,十分优秀!