繁体   English   中英

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

[英]Cannot run gatling test in IntelliJ

我们在gatling中进行了一些加载测试(用Scala编写),我们可以从命令运行测试但不能在IntelliJ中运行/调试它。 在IntelliJ中,我没有看到该类旁边没有绿色按钮(箭头),我可以单击并运行它; 右键单击弹出菜单中的该类,没有选项'run ClassName'或'debug ClassName'。 我想知道我们是否错误地定义了这个类。 这是测试类:

class IngestionTestExecution
    extends IngestionScenarios
    with TestScenariosExecution { ... }

trait IngestionScenarios extends CommonScenarios with RequestBuilders {..}

trait TestScenariosExecution extends Simulation with StrictLogging {...}

运行测试的命令行:

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

是的,我必须让我的测试类IngestionTestExecution直接扩展Simulation才能在IntelliJ中运行/调试?

要从IntelliJ运行Gatling项目,您需要下载IntelliJ的Scala插件 ,并且需要有一个项目入口点,即一个main方法。

例如:

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)
  }

}

小绿色按钮将出现在此对象旁边,也位于该方法旁边。 您还可以从头开始创建运行配置(通过“运行”>“编辑配置”),该对象将此对象指向主类。

我认为你的继承结构很好,特别是如果sbt运行测试。

暂无
暂无

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

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