我在这里给我的课做了注解
@RunWith(AndroidJUnit4.class)
public class WorkdayProviderTest
此外,还对我的测试方法进行了这样的注解
@Test
public void insert_dataInsertsCorrectly()
最后,配置我的build.gradle defaultConfig和依赖项,如下所示
defaultConfig {
applicationId 'com.jueggs.workinghours'
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
androidTestCompile "junit:junit:4.12"
androidTestCompile "com.android.support:support-annotations:23.3.0"
androidTestCompile "com.android.support.test:runner:0.4.1"
androidTestCompile "com.android.support.test:rules:0.4.1"
androidTestCompile "com.android.support.test.espresso:espresso-core:2.2.1"
androidTestCompile "com.android.support.test.espresso:espresso-contrib:2.2.1"
androidTestCompile "org.hamcrest:hamcrest-library:1.3"
No tests were found
Test running failed: Instrumentation run failed due to 'java.lang.ClassNotFoundException'
你可能没有什么东西在你的梯度依赖。是否正确声明了com.android.support.test:runner
(可选com.android.support.test:rule
)?
请看一下我的build.gradle
文件:
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.6'
}
}
apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
resourcePackageName "com.piotr.testexample"
}
}
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
useLibrary 'org.apache.http.legacy'
//For building with Travis CI
lintOptions {
abortOnError false
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
defaultConfig {
applicationId "com.piotr.testexample"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
ext.JUNIT_VERSION = '4.12'
ext.AA_VERSION = '4.0.0'
ext.SUPPORT_VERSION = '23.3.0'
ext.ESPRESSO_VERSION = '2.2.2'
apt "org.androidannotations:androidannotations:$AA_VERSION"
compile "org.androidannotations:androidannotations-api:$AA_VERSION"
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile "junit:junit:$JUNIT_VERSION"
testCompile("org.robolectric:robolectric:3.0") {
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'
}
compile "com.android.support:appcompat-v7:$SUPPORT_VERSION"
compile "com.android.support:design:$SUPPORT_VERSION"
compile "com.android.support:cardview-v7:$SUPPORT_VERSION"
compile "com.android.support:recyclerview-v7:$SUPPORT_VERSION"
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.google.code.gson:gson:2.4'
compile 'com.squareup.picasso:picasso:2.5.2'
androidTestCompile "com.android.support:support-annotations:$SUPPORT_VERSION"
androidTestCompile "com.android.support.test.espresso:espresso-core:$ESPRESSO_VERSION"
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile "com.android.support.test.espresso:espresso-intents:$ESPRESSO_VERSION"
/**
* AccessibilityChecks
* CountingIdlingResource
* DrawerActions
* DrawerMatchers
* PickerActions (Time and Date picker)
* RecyclerViewActions
*/
androidTestCompile("com.android.support.test.espresso:espresso-contrib:$ESPRESSO_VERSION") {
exclude group: 'com.android.support', module: 'appcompat'
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'support-v7'
exclude group: 'com.android.support', module: 'design'
exclude module: 'support-annotations'
exclude module: 'recyclerview-v7'
}
compile "junit:junit:${JUNIT_VERSION}"
}
编辑:问题是注释,请执行以下解决方案之一:
我已经看了所有其他对此的反应,但它们似乎不适用于我。 https://kotlinlang.org/api/latest/kotlin.test/kotlin.test/ 我正在尝试从暂存文件或.kt文件访问它,并且它不在下拉列表中以选择它。 项目正在使用JDK 15。
AndroidJUnit4 是一个让 JUnit 4 可以直接运行在 Android 设备上的开源工具。 示例代码: public class HelloActivity extends ActivityUnitTestCase<MyActivity> { /** * For Eclipse with ADT */ public static junit.framewo
在试图用PHPUnit设置Eclipse作为单元测试库时,我陷入了试图运行一个简单测试用例的困境。作为参考,我按照本教程使用PHPUnit/Xdebug/Makegood来设置Eclipse,唯一偏离给出的指导方针是为PHPUnit/Makegood设置以下配置文件: 现在,问题的根源在于,我似乎无法使用Makegood从Eclipse运行PHPUnit测试。我编写的唯一测试(位于名为test.p
我试图运行一个简单的Spring Boot测试,我得到的错误表明它不能在运行时MockMvc。文档表明我使用了正确的注释,并且我使用start.spring.io创建了我的pom.xml。不知道为什么会有问题。 错误: 测试代码 pom.xml
我已经为公司内测发布了我的应用程序,但无法从Play商店下载。 我已打开url“https://play.google.com/apps/testing/com.*并且被接受为一名测试人员,现在它向我展示了“你是一名测试人员”。但当我点击“从Play Store下载”链接时,它会在我的测试设备Play Store中显示“未找到项目”,并在桌面浏览器中显示“未找到请求的URL”。 应用程序处于已发布