Search code examples
gradleintellij-ideabuild.gradleappiumallure

How to change where Gradle 'Test' task saves file


I'm running into the following error when attempting to run my Appium testing framework. It seems like the "Test" task is trying to save the Allure report to a directory within the build directory and seems it can't write to it. How can I edit where this task saves the report? If anyone can point me in the right direction on where to look I'd be super grateful. Thank you so much! 🙏😀

A problem was found with the configuration of task ':test' (type 'Test').
  - Type 'org.gradle.api.tasks.testing.Test' property '$1' is not writable because '/Users/my_name/Documents/application_name/build/allure-results' is not a file.

This is my test code:

import org.testng.annotations.Test
import robot.WelcomeScreen

class LoginTest: BaseTest() {

    private val robot = WelcomeScreen()

    @Test(description = "User can log in with valid email and password")
    fun logInUsingValidEmailAndPassword() {
        // Obtain login screen from Robot
        robot.clickLoginOnWelcomeScreen()
            // perform actions and assertions from Robot
    }
}

And the below is my build.gradle file. I was trying to follow the same steps as the author of this repository https://github.com/automateITpro/appium-with-kotlin.

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "io.qameta.allure:allure-gradle:2.3"
    }
}

plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.6.21'
    id 'java'
}

group 'org.example'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
    mavenCentral()
}

apply plugin: 'io.qameta.allure'

allure {
    version = '2.4.1'
    autoconfigure = true
    aspectjweaver = true
    allureJavaVersion = "18.0.1"
}

dependencies {
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'

    implementation "io.insert-koin:koin-core:3.2.0"
    testImplementation "io.insert-koin:koin-test:3.2.0"

    implementation 'io.appium:java-client:8.1.1'
    implementation 'org.testng:testng:7.6.0'
    implementation "org.jetbrains.kotlin:kotlin-reflect:1.4.21"
    implementation "org.jetbrains.kotlin:kotlin-stdlib"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.21"
    implementation "com.github.automatedowl:allure-environment-writer:1.0.0"
}

configurations {
    testCompile
}

test {
    maxHeapSize = "6144m"
    jvmArgs "-XX:MaxMetaspaceSize=6144m"

    useTestNG() {
        useDefaultListeners = true
    }
}

Solution

  • The allure report can be customised to save results and report to specific paths, see amendment of your build.gradle below:

    allure {
        version = '2.4.1'
        autoconfigure = true
        aspectjweaver = true
        allureJavaVersion = "18.0.1"
        resultsDir = file('/path/to/test/results')
        reportDir = file('/path/to/trst/report')
    }
    

    Further details for configuration of Allure Reports can be found here: Allure Framework | Reporting | Gradle | Full Configuration