我尝试按照本教程在gradle的基础上,在我的Spring Boot项目中设置加特林: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
目录中生成报告。
关于spring-boot - 用gradle进行加特林特:尽管执行了操作,任务仍未声明任何输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60745559/