gpt4 book ai didi

android - 为什么我找不到测试?

转载 作者:太空宇宙 更新时间:2023-11-03 10:19:25 25 4
gpt4 key购买 nike

当使用以下配置执行 ./gradlew clean connectedAndroidTest 时...我得到 No tests found

这是我的build.gradle:

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.14.1'
classpath 'com.github.jcandksolutions.gradle:android-unit-test:2.0.1'
}
}

allprojects {
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
jcenter()
}
}

apply plugin: 'com.android.application'

android {
packagingOptions {
exclude 'LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LGP2.1'
exclude 'META-INF/LGPL2.1'
}
compileSdkVersion 21
buildToolsVersion "21.1.0"

lintOptions {
abortOnError false
}
defaultConfig {
applicationId "com.example"
minSdkVersion 9
targetSdkVersion 21
versionCode 2
versionName "0.1"
testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
}

buildTypes {
release {
runProguard false
}
}

sourceSets {
androidTest {
setRoot('src/espressoTest')
}
}
}

apply plugin: 'android-unit-test'

dependencies {
// App
compile 'com.android.support:support-v4:21.0.0'
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:gridlayout-v7:18.0.0'
compile 'joda-time:joda-time:2.3'
compile 'com.google.code.gson:gson:2.2.4'
compile 'de.greenrobot:eventbus:2.0.2'
compile 'com.squareup.dagger:dagger:1.1.0'
compile 'com.squareup.dagger:dagger-compiler:1.1.0'
compile 'com.google.android.gms:play-services:6.1.71'
compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'com.squareup.retrofit:retrofit:1.6.1'
compile 'com.squareup.picasso:picasso:2.3.4'
compile 'com.squareup:otto:1.3.5'
compile 'com.google.guava:guava:18.0'
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
compile 'com.viewpagerindicator:library:2.4.1@aar'
compile 'com.wrapp.floatlabelededittext:library:0.0.3'
compile 'com.daimajia.swipelayout:library:1.0.7@aar'
compile 'com.github.flavienlaurent.datetimepicker:library:0.0.2'
compile 'info.hoang8f:android-segmented:1.0.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.easing:library:1.0.0@aar'
compile 'com.daimajia.androidanimations:library:1.1.2@aar'
compile 'com.balysv.materialmenu:material-menu-toolbar:1.4.0'

// 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 'org.hamcrest:hamcrest-integration:1.1'
androidTestCompile 'org.hamcrest:hamcrest-core:1.1'
androidTestCompile 'org.hamcrest:hamcrest-library:1.1'

// Robolectric
testCompile('junit:junit:4.11') {
exclude module: 'hamcrest-core'
}
testCompile files('lib/robolectric-2.4-SNAPSHOT-jar-with-dependencies.jar')
testCompile 'org.mockito:mockito-all:1.9.5'
testCompile 'com.squareup:fest-android:1.0.+'
testCompile 'com.googlecode.catch-exception:catch-exception:1.2.0'
}

tasks.findByName("assembleDebug").dependsOn("testDebugClasses")

这是 src/espressoTest 下的测试类:

package com.example;

import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.LargeTest;

import com.betavalue.myvalue.MainActivity;
import com.betavalue.myvalue.R;

import static com.google.android.apps.common.testing.ui.espresso.Espresso.onView;
import static com.google.android.apps.common.testing.ui.espresso.assertion.ViewAssertions.matches;
import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withId;
import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withText;

@LargeTest
public class MainEspressoTest extends ActivityInstrumentationTestCase2<MainActivity> {

@SuppressWarnings("deprecation")
public MainEspressoTest() {
// This constructor was deprecated - but we want to support lower API levels.
super(MainActivity.class);
}
@Override
public void setUp() throws Exception {
super.setUp();
// Espresso will not launch our activity for us, we must launch it via getActivity().
getActivity();
}

public void testCheckText() {
onView(withId(R.id.text))
.check(matches(withText("Hello Espresso!")));
}
}

MainActivity 是一个空的 Activity,只是为了测试。

有什么想法吗? AndroidManifest.xml 中是否有我可能遗漏的内容?

最佳答案

如果有人遇到这个问题......它只是在再次从我的存储库中拉取它时自动解决。

它必须对 Android Studio 缓存做一些事情。

关于android - 为什么我找不到测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26908377/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com