简体   繁体   English

无法在IntelliJ中运行加特林测试

[英]Cannot run gatling test in IntelliJ

we have some load tests in gatling (written in Scala), we can run the test from command but cannot run/debug it in IntelliJ. 我们在gatling中进行了一些加载测试(用Scala编写),我们可以从命令运行测试但不能在IntelliJ中运行/调试它。 in the IntelliJ, i don't see there is no green button(arrow) next to that class that I can click and run it; 在IntelliJ中,我没有看到该类旁边没有绿色按钮(箭头),我可以单击并运行它; right click that class in the popup menu there is no option as 'run ClassName' or 'debug ClassName'. 右键单击弹出菜单中的该类,没有选项'run ClassName'或'debug ClassName'。 I'm wondering if we define the class wrong. 我想知道我们是否错误地定义了这个类。 here is the test class: 这是测试类:

class IngestionTestExecution
    extends IngestionScenarios
    with TestScenariosExecution { ... }

trait IngestionScenarios extends CommonScenarios with RequestBuilders {..}

trait TestScenariosExecution extends Simulation with StrictLogging {...}

the commandline to run the test: 运行测试的命令行:

sbt "project qaLoad" "gatling-it:testOnly com.example.load.gatling.execution.IngestionTestExecution"

is that true that i have to have my test class IngestionTestExecution directly extends Simulation in order to run/debug in IntelliJ? 是的,我必须让我的测试类IngestionTestExecution直接扩展Simulation才能在IntelliJ中运行/调试?

To run a Gatling project from IntelliJ, you need to download the Scala plugin for IntelliJ and you need to have an entry point to the project, namely a main method. 要从IntelliJ运行Gatling项目,您需要下载IntelliJ的Scala插件 ,并且需要有一个项目入口点,即一个main方法。

For example: 例如:

package com.example.project

object ApplicationRunner {

  def main(args: Array[String]): Unit = {

    val simClass: String = com.example.project.simulations.mySimulationClassName

    val props = new GatlingPropertiesBuilder().
      simulationClass(simClass)

    Gatling.fromMap(props.build)
  }

}

The little green button will appear next to this object and next to the method as well. 小绿色按钮将出现在此对象旁边,也位于该方法旁边。 You can also create a run config from scratch (via Run > Edit configurations), which points to this object as a main class. 您还可以从头开始创建运行配置(通过“运行”>“编辑配置”),该对象将此对象指向主类。

I think your inheritance structure is fine, especially if sbt runs the tests. 我认为你的继承结构很好,特别是如果sbt运行测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM