英文:
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("getOrderRequestScenario").forever
{
exec(
feed(csv("data/getOrderRequest.csv").batch.circular)
.exec(karateFeature(PathFinder.getPath("getOrderRequest.feature")))
.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("getOrderRequestScenario").forever {
exec(
feed(csv("data/getOrderRequest.csv").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("getOrderRequest.feature"))
In 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>
答案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("classpath:gratling/simulation/orderServices/getOrderRequest.feature"))
Else it is hard to troubleshoot, try your best to align with the documentation / sample projects.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论