简体   繁体   中英

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. in the IntelliJ, i don't see there is no green button(arrow) next to that class that I can click and run it; right click that class in the popup menu there is no option as 'run ClassName' or '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?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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