簡體   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