无效路径在性能测试中使用karateFeature。

huangapple go评论96阅读模式
英文:

Invalid path using karateFeature in performance test

问题

我找不到路径
java.lang.RuntimeException: 未找到:gratling/simulation/orderServices/getOrderRequest.feature

以下是在Scala文件中的内容。

package gratling.simulation.orderServices

class OrderSimulation extends Simulation {

  val getOrderRequest = scenario("getOrderRequestScenario").forever 
  {
     exec(
    	feed(csv("data/getOrderRequest.csv").batch.circular)
    	.exec(karateFeature(PathFinder.getPath("getOrderRequest.feature")))
    	.pause(pace seconds)
     )
  }
}

getOrderRequest.feature位于以下目录中

src
└── test
    └── resources
        └── gratling
            └── simulation
                └── orderServices
                   └──getOrderRequest.feature

通过使用Paths,我将无法运行下面显示的脚本

val orderFilePath= Paths.get("C:/XXX/src/test/scala/gratling/simulation/orderServices/getOrderRequest.feature").toAbsolutePath.toString

   val getOrderRequest= scenario("getOrderRequestScenario").forever {
  		exec(
    		feed(csv("data/getOrderRequest.csv").batch.circular)
    		.exec(karateFeature(orderFilePath))
    		.pause(pace seconds))}

但我正在尝试使用以下方式动态使用路径,而不是硬编码路径

karateFeature(PathFinder.getPath("getOrderRequest.feature"))

在pom.xml中

<plugin>
    <groupId>io.gatling</groupId>
     <artifactId>gatling-maven-plugin</artifactId>
     <version>${gatling.trial.run.plugin.version}</version>
     <configuration>
        <simulationsFolder>src/test/scala</simulationsFolder>
         <runMultipleSimulations>true</runMultipleSimulations>
         <includes>
                 <include>gratling.simulation.orderServices.OrderSimulation</include>
          </includes>
    </configuration>
</plugin>
英文:

I am getting path not found
java.lang.RuntimeException: not found: gratling/simulation/orderServices/getOrderRequest.feature

Below is what is written in scala file.

package gratling.simulation.orderServices

class OrderSimulation extends Simulation {

  val getOrderRequest = scenario(&quot;getOrderRequestScenario&quot;).forever 
  {
     exec(
    	feed(csv(&quot;data/getOrderRequest.csv&quot;).batch.circular)
    	.exec(karateFeature(PathFinder.getPath(&quot;getOrderRequest.feature&quot;)))
    	.pause(pace seconds)
     )
  }
}

getOrderRequest.feature is place in the directory

src
└── test
    └── resources
        └── gratling
            └── simulation
                └── orderServices
                   └──getOrderRequest.feature

By using Paths, I will have no issues running the script as shown below

val orderFilePath= Paths.get("C:/XXX/src/test/scala/gratling/simulation/orderServices/getOrderRequest.feature").toAbsolutePath.toString

   val getOrderRequest= scenario(&quot;getOrderRequestScenario&quot;).forever {
  		exec(
    		feed(csv(&quot;data/getOrderRequest.csv&quot;).batch.circular)
    		.exec(karateFeature(orderFilePath))
    		.pause(pace seconds))}

But I am trying to use the below dynamically instead of hardcoding the path

karateFeature(PathFinder.getPath(&quot;getOrderRequest.feature&quot;))

In pom.xml

&lt;plugin&gt;
    &lt;groupId&gt;io.gatling&lt;/groupId&gt;
     &lt;artifactId&gt;gatling-maven-plugin&lt;/artifactId&gt;
     &lt;version&gt;${gatling.trial.run.plugin.version}&lt;/version&gt;
     &lt;configuration&gt;
        &lt;simulationsFolder&gt;src/test/scala&lt;/simulationsFolder&gt;
         &lt;runMultipleSimulations&gt;true&lt;/runMultipleSimulations&gt;
         &lt;includes&gt;
                 &lt;include&gt;gratling.simulation.orderServices.OrderSimulation&lt;/include&gt;
          &lt;/includes&gt;
    &lt;/configuration&gt;
&lt;/plugin&gt;

答案1

得分: 1

The karateFeature() API is designed to use the same system that Karate uses.

So try this:

karateFeature("classpath:gratling/simulation/orderServices/getOrderRequest.feature"))

Else it is hard to troubleshoot, try your best to align with the documentation / sample projects.

英文:

The karateFeature() API is designed to use the same system that Karate uses.

So try this:

karateFeature(&quot;classpath:gratling/simulation/orderServices/getOrderRequest.feature&quot;))

Else it is hard to troubleshoot, try your best to align with the documentation / sample projects.

huangapple
  • 本文由 发表于 2023年5月28日 01:11:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/76348091.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定