使用 Gradle 进行空手道和加特林:运行崩溃了

问题描述 投票:0回答:1

无法运行用户定义的模拟类,因为可以加载模拟类

task gatlingRun(type: JavaExec) {
group = 'Web Tests'
description = 'Run Gatling Tests'
new File("${buildDir}/reports/gatling").mkdirs()
classpath = sourceSets.test.runtimeClasspath
main = "io.gatling.app.Gatling"
args = [
        // change this to suit your simulation entry-point
        '-s', 'performance.userSimulationIpay',
        '-rf', "${buildDir}/reports/gatling"
]
systemProperties System.properties}

这是添加到 gradle.build 文件中的任务,我使用的是 gradle 版本 6.9.1

enter image description here

这就是空手道框架结构。此外,我还使用 Maven 构建工具创建了相同的测试,并且性能测试按预期工作,当我使用 gradle 构建工具时遇到此问题。根据客户要求,我们必须从 Maven 迁移到 gradle,但是当我从终端执行以下命令时出现此异常。

enter image description here

我遇到的例外是:

 D:\Users\bakh\Automation\nlp_latest\AUT-Karate>gradle gatling

> Task :gatlingRun
18:08:56.346 [main] INFO  i.g.c.config.GatlingConfiguration$ - Gatling will try to use 'gatling.conf' as config file.
18:09:02.092 [GatlingSystem-akka.actor.default-dispatcher-6] INFO  akka.event.slf4j.Slf4jLogger - Slf4jLogger started
18:09:11.785 [main] ERROR io.gatling.app.Gatling$ - Run crashed
java.lang.IllegalArgumentException: User defined Simulation class performance.userSimulationIpay could not be loaded
        at io.gatling.app.Selection$Selector.findUserDefinedSimulationInClassloader$1(Selection.scala:80)
        at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$4(Selection.scala:85)
        at scala.Option.orElse(Option.scala:477)
        at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$3(Selection.scala:85)
        at scala.Option.flatMap(Option.scala:283)
        at io.gatling.app.Selection$Selector.singleSimulationFromConfig(Selection.scala:83)
        at io.gatling.app.Selection$Selector.$anonfun$selection$1(Selection.scala:52)
        at scala.Option.getOrElse(Option.scala:201)
        at io.gatling.app.Selection$Selector.selection(Selection.scala:44)
        at io.gatling.app.Selection$.apply(Selection.scala:36)
        at io.gatling.app.Runner.run0(Runner.scala:61)
        at io.gatling.app.Runner.run(Runner.scala:49)
        at io.gatling.app.Gatling$.start(Gatling.scala:83)
        at io.gatling.app.Gatling$.fromArgs(Gatling.scala:45)
        at io.gatling.app.Gatling$.main(Gatling.scala:37)
        at io.gatling.app.Gatling.main(Gatling.scala)
Caused by: java.lang.ClassNotFoundException: performance.userSimulationIpay
        at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:264)
        at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$2(Selection.scala:71)
        at scala.util.Try$.apply(Try.scala:210)
        at io.gatling.app.Selection$Selector.findUserDefinedSimulationInClassloader$1(Selection.scala:71)
        ... 15 common frames omitted
Exception in thread "main" java.lang.IllegalArgumentException: User defined Simulation class performance.userSimulationIpay could not be loaded
        at io.gatling.app.Selection$Selector.findUserDefinedSimulationInClassloader$1(Selection.scala:80)
        at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$4(Selection.scala:85)
        at scala.Option.orElse(Option.scala:477)
        at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$3(Selection.scala:85)
        at scala.Option.flatMap(Option.scala:283)
        at io.gatling.app.Selection$Selector.singleSimulationFromConfig(Selection.scala:83)
        at io.gatling.app.Selection$Selector.$anonfun$selection$1(Selection.scala:52)
        at scala.Option.getOrElse(Option.scala:201)
        at io.gatling.app.Selection$Selector.selection(Selection.scala:44)
        at io.gatling.app.Selection$.apply(Selection.scala:36)
        at io.gatling.app.Runner.run0(Runner.scala:61)
        at io.gatling.app.Runner.run(Runner.scala:49)
        at io.gatling.app.Gatling$.start(Gatling.scala:83)
        at io.gatling.app.Gatling$.fromArgs(Gatling.scala:45)
        at io.gatling.app.Gatling$.main(Gatling.scala:37)
        at io.gatling.app.Gatling.main(Gatling.scala)
Caused by: java.lang.ClassNotFoundException: performance.userSimulationIpay
        at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:264)
        at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$2(Selection.scala:71)
        at scala.util.Try$.apply(Try.scala:210)
        at io.gatling.app.Selection$Selector.findUserDefinedSimulationInClassloader$1(Selection.scala:71)
        ... 15 more

> Task :gatlingRun FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':gatlingRun'.
> Process 'command 'C:\Program Files\Amazon Corretto\jdk1.8.0_282\bin\java.exe'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 2m 26s
gradle karate
1个回答
1
投票

尝试将您的模拟移动到名为“gatting”的专用

sourceSet
,其子目录为“scala”(因为您的模拟是用 scala 而不是 java 编写的),并按照此处的说明进行操作:https://docs。 galing.io/reference/integrations/build-tools/gradle-plugin/

© www.soinside.com 2019 - 2024. All rights reserved.