3

I have set up a gatling project in Intellij IDEA 14.4 community edition. I have the Scala plugin installed and the project configuration seems to be correct (since I do not see and inline errors and compile works fine). However I have red in some tutorials that you can also run the current file by right clicking on it and choosing run or debug. I do not see these options and I cannot figure why:

enter image description here

I have tried Invalidate Caches / Restart but that did not work either...

EDIT:

I should have mentioned I have no experience with scala. What I am trying to do is actually run individual gatling simulations from Intellij because it is more convenient and I can also debug them. Most of the code I have is based on examples but in reality I have no idea what I am doing. So to reformulate, let's say I have the following simulation file PingSimulation.scala. Where should I add the main() function to be able to run the file individually in Intellij?

package atlas

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._

class PingSimulation extends Simulation {
  object Ping {
    val ping = exec(http("Ping")
      .get("/ping")
    )
  }

  val httpConf = http.baseURL(Endpoints.testing_url)

  val scn = scenario("Ping").exec(Ping.ping)

  setUp(
    scn.inject(atOnceUsers(1)).protocols(httpConf)
  )
}
skamsie
  • 2,614
  • 5
  • 36
  • 48

1 Answers1

3

From your screenshot there doesn't seem to be anything to run in scope. You need to have either an object that extends App or provides a def main. A class itself cannot be run.

Arne Claassen
  • 14,088
  • 5
  • 67
  • 106
  • Also, once you do what Arne is suggesting you may have to close and re-import your project as an SBT project so that it will recognize the file. I've seen that happen on occasion in IntelliJ 13. – Jason D Aug 12 '15 at 18:22
  • Thank you for the answer Arne but I am a complete n00b when it comes to scala or any JVM language in fact, so can you please elaborate more? I have updated my question accordingly :) – skamsie Aug 12 '15 at 19:55
  • I have not used Gatling, but from a quick scan of the documenation, it seems that you need to have Gatling execute your Simulation class, you can't run it directly. This seems to be possible from within IntelliJ, but I saw no up to date information, but you may want to start here: https://gist.github.com/groovybayo/4691670 – Arne Claassen Aug 12 '15 at 20:01
  • @ArneClaassen thank you for the answer. For some reason IntelliJ does not recognize `def main(){}` but does recognize `extends App`. The latter worked well for me in IntelliJ 2016.1 – autronix Jul 03 '16 at 04:17