Gatling with gradle:尽管执行了操作,任务仍未声明任何输出

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

我尝试在我的 Spring 引导项目中设置 gatling,基于 gradle,遵循本教程:http://brokenrhythm.blog/gradle-gatling-springboot-automation

这是我写的任务:

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' };
}

但是当运行 runGatling时,我遇到了以下错误:

> 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.

@george-leung 是对的,gradle-plugin解决了我的问题。谢谢:)

这里是 build.gradle 配置:

plugins {
    id 'scala'
    id "com.github.lkishalmi.gatling" version "3.3.0"
}

dependencies {
    compile 'org.scala-lang:scala-library:2.12.10'
}

模拟文件必须在目录src/gatling/simulations.

然后 运行 gradlew gatlingRun 命令执行负载测试,默认情况下在 build/reports/gatling 目录中生成报告。