Search code examples
spring-bootgradlegatlingscala-gatling

Gatling with gradle: Task has not declared any outputs despite executing actions


I try to setup gatling in my Spring Boot project, based on gradle, following this tutorial: http://brokenrhythm.blog/gradle-gatling-springboot-automation

Here is the tasks I wrote:

task runGatling(type: JavaExec) {
    description = 'Test load the Spring Boot web service with Gatling'
    group = 'Load Test'
    classpath = sourceSets.test.runtimeClasspath
    jvmArgs = [
            // workaround for https://github.com/gatling/gatling/issues/2689
            "-Dgatling.core.directory.binaries=${sourceSets.test.output.classesDirs.toString()}",
            "-Dlogback.configurationFile=${logbackGatlingConfig()}"
    ]
    main = 'io.gatling.app.Gatling'
    args = [
            '--simulation', 'com.mypackage.loadtesting.Simulation',
            '--results-folder', "${buildDir}/gatling-results",
            '--binaries-folder', sourceSets.test.output.classesDirs.toString() // ignored because of above bug
    ]
}

def logbackGatlingConfig() {
    return sourceSets.test.resources.find { it.name == 'logback-gatling.xml' };
}

But when running runGatling, I reach the following error:

> Task :runGatling FAILED
Caching disabled for task ':runGatling' because:
  Caching has not been enabled for the task
Task ':runGatling' is not up-to-date because:
  Task has not declared any outputs despite executing actions.

Solution

  • @george-leung is right, gradle-plugin solved my issue. Thanks :)

    Here is the build.gradle configuration:

    plugins {
        id 'scala'
        id "com.github.lkishalmi.gatling" version "3.3.0"
    }
    
    dependencies {
        compile 'org.scala-lang:scala-library:2.12.10'
    }
    

    The simulation file must be in the directory src/gatling/simulations.

    Then just run the gradlew gatlingRun command an it performs the load tests, generating a report in the build/reports/gatling directory by default.