Abe
Abe

Reputation: 1415

Gatling - How to import objects from packages

I wish to have a file containing util variables to reuse inside my simulations classes but I'm getting these errors:

18:15:22.702 [ERROR] i.g.c.ZincCompiler$ - /app/simulations/keyword_search/test.scala:9:20: object Args is not a member of package simulations
import simulations.Args._
                   ^
18:15:22.711 [ERROR] i.g.c.ZincCompiler$ - /app/simulations/keyword_search/test.scala:12:13: not found: value name
    println(name)
            ^
18:15:22.726 [ERROR] i.g.c.ZincCompiler$ - two errors found
18:15:22.740 [ERROR] i.g.c.ZincCompiler$ - Compilation crashed

I have the following scenario:

Project path:

simulations/
--keyword_search/
----test.scala
--args.scala

simulations/args.scala file:

package simulations

object Args {
  val name = "bla"
}

simulations/keyword_search/test.scala file:

package simulations.keyword_search

import simulations.Args._

class Test extends Simulation {
  print(name)
}

I'm running gatling with following script:

gatling -sf /app/simulations/keyword_search -s simulations.keyword_search.Test

Is this correct ? Am I missing something ?

Upvotes: 2

Views: 989

Answers (2)

Muhammad Zeeshan
Muhammad Zeeshan

Reputation: 4748

You can import package as:

import users._  // import everything from the users package
import users.User  // import the class User
import users.{User, UserPreferences}  // Only imports selected members
import users.{UserPreferences => UPrefs}  // import and rename for convenience

Upvotes: 0

Daniel
Daniel

Reputation: 783

Gatling is not aware of args.scala, since the file is outside the directory specified as simulations folder -sf. Please run your Gatling simulation using /app/simulations as a simulations folder:

gatling -sf /app/simulations -s simulations.keyword_search.Test

Upvotes: 3

Related Questions