简体   繁体   English

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

[英]How to generate html report with gradle 1.12?

Anyone knows how to generate test report for gradle 1.12? 任何人都知道如何为gradle 1.12生成测试报告?

I'm using gradle 1.12. 我正在使用gradle 1.12。 My Test extends ActivityInstrumentationTestCase2. 我的测试扩展了ActivityInstrumentationTestCase2。 using Espresso test framework. 使用Espresso测试框架。 My test run but doesn't generate html report. 我的测试运行但不生成html报告。

Here's my build.gradle: 这是我的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 {
    }
}

I run my test using shell script Here's my shell script: 我使用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

The result in command prompt: 命令提示符中的结果:

...
BUILD SUCCESSFUL

Total time: 55.003 secs

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

OK (1 test)

If fail 如果失败

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

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

See Gradle userguide by navigating to Example 23.14. 见摇篮userguide通过导航到实施例23.14。 Creating a unit test report for subprojects 为子项目创建单元测试报告

Also see this post 另见这篇文章

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM