如何使用gradle 1.12生成html报告?

时间:2014-08-05 10:11:10

标签: android testing gradle automated-tests

任何人都知道如何为gradle 1.12生成测试报告?

我正在使用gradle 1.12。我的测试扩展了ActivityInstrumentationTestCase2。使用Espresso测试框架。我的测试运行但不生成html报告。

这是我的build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'crashlytics'

repositories {
    maven { url 'http://download.crashlytics.com/maven' }
    maven { url 'http://JRAF.org/static/maven/2' }
    jcenter()
}
dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    ...
}
android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion
    def Properties versionProps = new Properties()
    versionProps.load(new FileInputStream(file('version.properties')))
    defaultConfig {
        applicationId 'com.android.apps'
        minSdkVersion 9
        targetSdkVersion 20
        versionName versionProps['name']
        versionCode versionProps['code'].toInteger()
        testApplicationId 'my.test'
        testInstrumentationRunner 'com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner'
    }
    android {
        useOldManifestMerger true
    }
    packagingOptions {
        exclude 'META-INF/services/javax.annotation.processing.Processor'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    lintOptions {
        abortOnError false
    }
    productFlavors {
    }
}

我使用shell脚本运行我的测试 这是我的shell脚本:

# Clean and Build the project
gradle clean build
# Install apk to device
gradle installDebug installDebugTest

# Run specific test
/Applications/Android\ Studio.app/sdk/platform-tools/adb shell am instrument -e class my.test.RunTestSuite -w my.test/com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner

命令提示符中的结果:

...
BUILD SUCCESSFUL

Total time: 55.003 secs

my.test.TestActionBar:.
Test results for GoogleInstrumentationTestRunner$BridgeTestRunner=.
Time: 32.519

OK (1 test)

如果失败

Test results for GoogleInstrumentationTestRunner$BridgeTestRunner=.E
Time: 29.595

FAILURES!!!
Tests run: 1,  Failures: 0,  Errors: 1

1 个答案:

答案 0 :(得分:3)

导航到示例23.14,请参阅Gradle userguide。为子项目创建单元测试报告

另见post