GatlingSystem-akka.actor.default-dispatcher-2错误-运行空手道加特林测试时因'j.l.NullPointerException'崩溃

时间:2019-11-08 18:09:29

标签: karate

当我尝试使用空手道运行Gatling性能测试时,我在错误日志中得到以下内容。

Simulation perf.SVTKarateSimulation started...
17:55:28.277 [GatlingSystem-akka.actor.default-dispatcher-2][ERROR][Action.scala:71] c.i.k.g.KarateAction - 'classpath:com/TCEU/KarateTests/Test.feature' crashed with 'j.l.NullPointerException', forwarding to the next one

这是我的pom文件的外观:


            <plugin>
                <groupId>io.gatling</groupId>
                <artifactId>gatling-maven-plugin</artifactId>
                <version>3.0.4</version>
                <configuration>
                    <simulationsFolder>src/test/java</simulationsFolder>
                    <includes>
                        <include>perf.SVTKarateSimulation</include>
                    </includes>
                    <jvmArgs>
                        <jvmArg>-Dfile.encoding=UTF-8</jvmArg>
                    </jvmArgs>
                </configuration>
            </plugin>    

并使用Karate-Gatling 0.9.5.RC4

这是我的scala文件:

package perf

import com.intuit.karate.gatling.PreDef._
import io.gatling.core.Predef._
import scala.concurrent.duration._
import io.gatling.http.Predef._

class SVTKarateSimulation extends Simulation {

  val create = scenario("Get api").exec(karateFeature("classpath:com/TCEU/KarateTests/test.feature"))

  setUp(
    create.inject(rampUsers(10) during (10 seconds)))

}

还有test.feature文件:

Feature: Gatling test

    Background: 
    * url 'https://regres.in'

    Scenario: Get api

        Given path '/api/users/2'
        When method GET
        Then status 200

我查看了

中提供的解决方案

Crashed with 'j.l.NullPointerException' when i try to run karate-gatling test reports

以及 https://github.com/intuit/karate/issues/404

但是其中提供的解决方案也无济于事。

我正在使用Windows 10和Eclipse版本:2019-09 R(4.13.0)。

我试图运行另一个与项目相关的功能文件,但给出了相同的错误,因此尝试了一个视频教程之后的简单测试-https://www.youtube.com/watch?v=RrRhndl-osY

有人可以帮忙吗?

2 个答案:

答案 0 :(得分:0)

对于其他遇到此问题的人来说,解决方案是使pom.xml与相同版本的Karate保持一致。我的空手道得分为0.9.5.RC4,而空手道阿帕奇的得分为0.9.4。当我将它们都设置为0.9.5.RC4时,我没有遇到这些问题。确保pom.xml一致。

答案 1 :(得分:0)

如果有人在编译/运行时遇到这种问题:

15:22:28.250 [main] ERROR io.gatling.compiler.ZincCompiler$ - one error found
15:22:28.252 [main] ERROR io.gatling.compiler.ZincCompiler$ - Compilation crashed
sbt.internal.inc.CompileFailed: null
        at sbt.internal.inc.AnalyzingCompiler.call(AnalyzingCompiler.scala:242)
        at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:111)
        at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:90)
        at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$3(MixedAnalyzingCompiler.scala:82)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
        at sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:133)
        at sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:73)
        at sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:116)
        at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:307)
        at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:307)
        at sbt.internal.inc.Incremental$.doCompile(Incremental.scala:106)
        at sbt.internal.inc.Incremental$.$anonfun$compile$4(Incremental.scala:87)
        at sbt.internal.inc.IncrementalCommon.recompileClasses(IncrementalCommon.scala:116)
        at sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:63)
        at sbt.internal.inc.Incremental$.$anonfun$compile$3(Incremental.scala:89)
        at sbt.internal.inc.Incremental$.manageClassfiles(Incremental.scala:134)
        at sbt.internal.inc.Incremental$.compile(Incremental.scala:80)
        at sbt.internal.inc.IncrementalCompile$.apply(Compile.scala:67)
        at sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:311)
        at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:269)
        at sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:159)
        at sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:238)
        at sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:69)
        at io.gatling.compiler.ZincCompiler$.doCompile(ZincCompiler.scala:210)
        at io.gatling.compiler.ZincCompiler$.delayedEndpoint$io$gatling$compiler$ZincCompiler$1(ZincCompiler.scala:215)
        at io.gatling.compiler.ZincCompiler$delayedInit$body.apply(ZincCompiler.scala:39)
        at scala.Function0.apply$mcV$sp(Function0.scala:39)
        at scala.Function0.apply$mcV$sp$(Function0.scala:39)
        at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17)
        at scala.App.$anonfun$main$1$adapted(App.scala:80)
        at scala.collection.immutable.List.foreach(List.scala:392)
        at scala.App.main(App.scala:80)
        at scala.App.main$(App.scala:78)
        at io.gatling.compiler.ZincCompiler$.main(ZincCompiler.scala:39)
        at io.gatling.compiler.ZincCompiler.main(ZincCompiler.scala)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at io.gatling.mojo.MainWithArgsInFile.runMain(MainWithArgsInFile.java:50)
        at io.gatling.mojo.MainWithArgsInFile.main(MainWithArgsInFile.java:33)

这可能是因为在 Windows 上,Java bin 文件夹未添加到系统 PATH。有关更多详细信息,请参阅以下主题。

https://github.com/intuit/karate/issues/404#issuecomment-417630286