gpt4 book ai didi

testing - 使用 gradle 进行双份 Espresso 测试 - 空测试套件

转载 作者:行者123 更新时间:2023-11-28 20:15:21 28 4
gpt4 key购买 nike

我正在尝试使用 Espresso 来测试我的应用程序。正如我在其他帖子中发现的那样,我将使用带有 gradle 的纯 Espresso 代替双份 Espresso 。 Doulbe espresso 可在此处找到:https://github.com/JakeWharton/double-espresso .

我配置了这样的运行配置:http://wiki.android-test-kit.googlecode.com/git/android-studio-new-run-configuration.png .当我执行它时,过了一会儿它说 Empty Test Suite

我在 androidTest/java 目录中创建了以下测试类:包 com.myapp.mobileapp.test.ui;

@LargeTest
public class LoginTest extends ActivityInstrumentationTestCase2<LoginActivity> {

public LoginTest(Class<LoginActivity> activityClass) {
super(activityClass);
}

@Override
public void setUp() throws Exception {
super.setUp();
getActivity();
}

@SmallTest
public void testLogin() {
onView(withId(R.id.buttonLogin))
.perform(click());
assertTrue(true);
}
}

我的项目有一个 top 项目,有 apk 项目和 facebook library 项目。

顶级项目的构建文件如下:

// Top-level build file where you can add configuration options common to all     sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.11.+'
}
}

allprojects {
repositories {
mavenCentral()
}
}

apk 项目的构建文件如下:

apply plugin: 'android'

android {
compileSdkVersion 18
buildToolsVersion "19.1.0"

// https://code.google.com/p/android/issues/detail?id=71147
useOldManifestMerger true

defaultConfig {
applicationId "com.myapp.mobileapp"
minSdkVersion 14
targetSdkVersion 18

testApplicationId "com.myapp.mobileapp.test"
testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
}

buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard- rules.txt'
}
debug {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard- rules.pro'
}
}

packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/LICENSE'
exclude 'LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/ASL2.0'
}
}

dependencies {

// OTHERS
compile 'com.android.support:support-v4:18.0.0'
compile('com.google.code.gson:gson:2.2.4')

// GOOGLE PLAY SERVICES
compile 'com.android.support:appcompat-v7:+'
compile 'com.google.android.gms:play-services:3.2.65'

// FACEBOOK
compile project(':facebookSDK')

// CHAT LIBRARY
compile files('libs/asmack-android-18-0.8.10.jar')

// GOOGLE ANALITICS
compile files('libs/libGoogleAnalyticsServices.jar')

// ORMLITE
compile 'com.j256.ormlite:ormlite-core:4.41'
compile 'com.j256.ormlite:ormlite-android:4.41'

// ROBOSPICE
compile('com.octo.android.robospice:robospice:1.4.6') {
exclude module: 'support-v4'
}
compile('com.octo.android.robospice:robospice-spring-android:1.4.6') {
exclude module: 'support-v4'
}
compile('org.codehaus.jackson:jackson-mapper-asl:1.9.11')

// LOGGING
compile files('libs/slf4j-api-1.7.5.jar')
compile files('libs/logback-android-1.0.10-2.jar')

// VOLLEY
compile files('libs/volley.jar')

// TESTING TOOLS
androidTestCompile('com.jakewharton.espresso:espresso:1.1-r3')
}

我使用以下工具:

安卓工作室 0.6.1

(在 android studio 中内置 gradle)gradlew --version

Gradle 1.10

构建时间:2013-12-17 09:28:15 UTC内部版本号:无修订:36ced393628875ff15575fa03d16c1349ffe8bb6

常规:1.8.6

Ant:Apache Ant(TM) 版本 1.9.2

Ivy :2.2.0

JVM:1.8.0_05(甲骨文公司 25.5-b02)

操作系统:Windows 8.1 6.3 amd64

最佳答案

您可能遇到异常,因此请检查日志。

构造器需要像这样:

public LoginTest() {
super(LoginActivity.class);
}

类似问答: Espresso testing android

关于testing - 使用 gradle 进行双份 Espresso 测试 - 空测试套件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24224849/

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