Creating shared library and use it across gatling projects

Hi,

I have 4 repo/gatling projects. And there are many methods like login, logout, getItem, etc., which are duplicated across all those projects.
Is there a way to create a shared library (similar to node modules) and import those library and call them in those projects instead of duplicating lot of methods across projects?

Can you please suggest some idea ?

Regards,
Vinodh

Team… Does any one have an idea?

You can try something like below:

1st file, Setup:

`
object WWWSetup {
val httpProtocol = http
.baseURL("…/api")

object LoginAsAdmin {
val LoginAsAdmin = exec(http(“Login as Admin”)
)}

object OpenNews {
val OpenNews = exec(http(“Open News Page”)
)}
`

2d file, Test

`
import WWWSetup ._

class WWW_test extends Simulation {
val admin = scenario(“admin”).exec(WWWSetup.LoginAsAdmin.LoginAsAdmin, WWWSetup.OpenNews.OpenNews )
`

Actually its here - http://gatling.io/docs/2.2.3/advanced_tutorial.html

@Nikolay, Thanks for your response.
This is more like creating the file with objects and using them in a test file within a single project.

How can i use this WWWSetup file across different projects/repositories.

Project 1 : /Users/vinodh/project1/gatling/src/test/scala/simulations/Login.scala

Project 2 : /Users/vinodh/testProject2/gatling/src/test/scala/simulations/Login.scala

Project 3 : /Users/vinodh/developmentProject3/gatling/src/test/scala/simulations/Login.scala

So this is my case. I have an object file Login.scala across three projects/repositories. Content in these files are the same. There are many such files which can be shared across projects/repositories.

So back to my question, Is there a way to create a shared library (similar to node modules) and import those library and call them in those projects instead of duplicating lot of methods across projects?

I have created a couple of maven artefacts that I published to our internal maven repository. In my Gatling projects I simply declare the dependency in the pom.xml and add the import statements in the Gatling scripts, so I can then execute stuff like SharedActions.login, SharedActions.logout, etc.

Read up on maven if you haven’t done so previously.