简体   繁体   中英

Gradle generate custom test report

I need a bit of help building custom test reports.

Each test would have an output like 'result x', 'result y' which would then be stored in either 1 global report file or 1 report per test.

A naive approach would be to use the 'tear down' part of each test to append the info in a global file.

The output file shouldn't interfere with junit, jacoco or other reports.

Can this be achieved by doing a custom gradle plugin or reusing some functionality in other plugins?

Thank you

The gradle Test task supports custom TestListener s. There's also convenience methods for beforeTest and afterTest

eg:

apply plugin: 'java'
test {
    afterTest { TestDescriptor td, TestResult tr ->
        writeToSomeFile(td.className, td.name, tr.resultType.name())
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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