- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已成功安装 Robolectric,但我的测试根本没有运行。没有错误,但也没有结果。我错过了什么?
运行./gradlew test 后没有测试报告,但是测试类生成正确
我的build.gradle:
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/repo' }
}
dependencies {
...
classpath 'io.fabric.tools:gradle:1.+'
classpath 'org.robolectric:robolectric-gradle-plugin:0.11.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'idea'
apply plugin: 'hugo'
apply plugin: 'android'
apply plugin: 'robolectric'
idea {
module {
downloadJavadoc = true
downloadSources = true
testOutputDir = file('build/test-classes/debug')
}
}
repositories {
mavenCentral()
maven { url 'https://repo.commonsware.com.s3.amazonaws.com' }
flatDir name: 'localRepository', dirs: 'libs-aar'
maven { url 'https://maven.fabric.io/repo' }
}
dependencies {
repositories {
mavenCentral()
}
...
// Espresso
androidTestCompile files('lib/espresso-1.1.jar', 'lib/testrunner-1.1.jar', 'lib/testrunner-runtime-1.1.jar')
androidTestCompile 'com.google.guava:guava:14.0.1'
androidTestCompile 'com.squareup.dagger:dagger:1.1.0'
androidTestCompile 'org.hamcrest:hamcrest-integration:1.1'
androidTestCompile 'org.hamcrest:hamcrest-core:1.1'
androidTestCompile 'org.hamcrest:hamcrest-library:1.1'
androidTestCompile('junit:junit:4.11') {
exclude module: 'hamcrest-core'
}
androidTestCompile('org.robolectric:robolectric:2.3') {
exclude module: 'classworlds'
exclude module: 'commons-logging'
exclude module: 'httpclient'
exclude module: 'maven-artifact'
exclude module: 'maven-artifact-manager'
exclude module: 'maven-error-diagnostics'
exclude module: 'maven-model'
exclude module: 'maven-project'
exclude module: 'maven-settings'
exclude module: 'plexus-container-default'
exclude module: 'plexus-interpolation'
exclude module: 'plexus-utils'
exclude module: 'wagon-file'
exclude module: 'wagon-http-lightweight'
exclude module: 'wagon-provider-api'
}
androidTestCompile 'com.squareup:fest-android:1.0.+'
}
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
useOldManifestMerger true
defaultConfig {
minSdkVersion 11
targetSdkVersion 19
buildConfigField "String", "GIT_SHA", "\"${gitSha()}\""
testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
// buildConfigField "String", "BUILD_TIME", buildTime()
}
...
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src/com', 'src/se', 'src/viewpagerindicator' , 'src-gen']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
...
androidTest {
setRoot('src/androidTest')
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}
...
robolectric {
include '**/*Tests.class'
exclude '**/espresso/**/*.class'
}
我的测试:
@RunWith(RobolectricTestRunner.class)
public class StartTest {
@Test
public void testSomething() throws Exception {
//Activity activity = Robolectric.buildActivity(DeckardActivity.class).create().get();
assertTrue(true);
}
}
最佳答案
我认为问题出在您的文件掩码上。您包含了 Tests.class,但您的类名为 StartTest(请注意缺少的 s),因此它不会被包含在内。
关于android - Robolectric 测试未运行 (Android),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26774993/
有没有办法在使用 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 模块并
我是一名优秀的程序员,十分优秀!