Set custom path on JUnit report?


I am trying to set a custom path on the JUnit report. I am using Android and the default paths are build/reports/tests/testDebugUnitTest and build/reports/tests/testReleaseUnitTest

Any help would really be appreciated!

you should be able to configure the html and xml output explicitly per task. In the following example I apply a custom directory for each task of type test and use the task name to build up the report path:

test {
    reports.junitXml.destination = file("$buildDir/xml")
    reports.html.destination = file("$buildDir/html")

Thanks a lot! Where exactly I put this in my gradle file please?

it shouldn’t matter where in your build file you put this snippet

Thanks a lot for the help! I am the same guy who asked the SO question…!

I am a beginner in this and I can’t get it to work…

In my android project I have 2 gradle files.

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
    dependencies {
        classpath ''

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files

allprojects {
    repositories {
        maven { url "" }

task clean(type: Delete) {
    delete rootProject.buildDir


apply plugin: ''

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId ""
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner ""
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), ''

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('', {
        exclude group: '', module: 'support-annotations'
    compile ''
    testCompile 'junit:junit:4.12'

Can you please tell me where in these files I should add this please?

Thanks a ton for the help! I am really thankful!

I am running the build with the command gradlew clean testReleaseUnitTest

as mentioned, you should be fine just putting the snippet at the bottom of your build script of the android build script. otherwise to be safe you could also put it into the allprojects section of the root build.gradle file