Jenkins CI - 使用TestObject的Gradle Build Plugin

时间:2016-08-20 16:34:56

标签: android jenkins android-gradle android-espresso

我正在尝试使用TestObject的Gradle构建插件自动执行Espresso测试(请参阅:https://testobject.com/blog/2015/11/testobject-gradle-plugin.html)。我修改了我的gradle.build文件,如下所示:

buildscript {
    repositories {
        mavenCentral()
        maven { url 'http://nexus.testobject.org/nexus/content/repositories/testobject-public-repo' }
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.2'
        classpath 'com.android.tools.build:gradle:0.12+'
        classpath group: 'org.testobject', name: 'testobject-gradle-plugin', version: '0.0.39'
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

apply plugin: 'android'
apply plugin: 'testobject'

android {
    compileSdkVersion 24
    buildToolsVersion '24.0.0'
lintOptions {
        abortOnError false
    }
    defaultConfig {
        applicationId "com.domain.appname"
        // For production release, this should be v17
        minSdkVersion 18
        targetSdkVersion 24
        versionCode 2
        versionName "0.1.7"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    dataBinding {
        enabled = true
    }
}

testobject {
    username "username"
    password "password"
    team "team-name"
    app "app-name"
    testSuite 8
    runAsPackage true
    failOnUnknown true
    sizes = ["small","medium","large"]
}

dependencies {
    androidTestCompile 'com.android.support.test:runner:0.3'
    androidTestCompile 'com.android.support.test:rules:0.3'
    androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2'

    androidTestCompile 'com.android.support:support-annotations:24.0.0'
    compile 'com.android.support:appcompat-v7:24.0.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.parse.bolts:bolts-android:1.+'
    compile 'com.parse:parse-android:1.+'
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.google.android.gms:play-services:9.0.1'
    compile 'com.google.code.gson:gson:2.6.2'
    compile('com.crashlytics.sdk.android:crashlytics:2.5.6@aar') {
        transitive = true;
    }
}

但是当我跑步" gradle build"它没有创建一个文件夹" testobject"在" build"目录,如文档中指定的。有谁知道我做错了什么以及如何解决这个问题?关于如何使用TestObject / Jenkins CI自动化测试的任何其他建议(/教程)也将不胜感激。

1 个答案:

答案 0 :(得分:1)

Android项目中有2个不同的构建目录。其中一个位于项目根目录下,另一个位于app目录下。我们在第二个下创建XML。如果在项目的根文件夹中运行此命令,则可以轻松找到该文件夹​​:

find * -type d | grep testobject

为了进一步帮助您,我建议您不要设置runAsPackage配置,因为这仅建议使用自定义Test Runner的客户。如果您只想运行所有测试,也不需要大小配置。