Gatling saying Class not found The requested class 'com.xxxxx.performace.test.gatling.UserCreationSimulation' can not be found in the classpath or does not extends Simulation.

Hi All

BackGround:Bit new to Gatling and scala thing,so excuse me if I ask stupid question.

Objective:TO performance test our API endpoints on Google Cloud Server(VM).

Tools:Gatling and writing a custom scala code to test end points.

package com.enwintra.performace.test.gatling

import io.gatling.core.Predef._

import io.gatling.core.scenario.Simulation

import io.gatling.http.Predef._

class UserCreationSimulation extends Simulation {

val httpEndPointConf = http.baseURL(“https://xxxxxxx.appspot.com”).acceptHeader(“application/json”)

val scn = scenario(“UserCreation”).exec(PerformanceTaskCreation.createUser)

setUp(scn.inject(rampUsers(10000) over (10))).protocols(httpEndPointConf)

}

package com.xxxx.performace.test.gatling

class User{

var email:String=_

var username:String=_

var password:String =_

}

package com.enwintra.performace.test.gatling

import io.gatling.http.Predef._

import io.gatling.core.Predef._

object PerformanceTaskCreation {

val createUser = exec(

http(“createUser”)

.post("/signup")

.header(“Content-Type”, “application/json”)

.body(StringBody(GenerateUsers.getRandomUser())

))

}

package com.enwintra.performace.test.gatling

import scala.util.Random

import com.enwintra.performace.test.gatling.User

import com.google.gson.Gson

object GenerateUsers {

val users = Array(“bhanu”, “saagr”, “domil”, “bharat”)

val mails = Array(“aaa@mail.com”, “bb@mail.com”, “cc@mail.com”, “dd@mail.com”)

def getRandomUser(): String = {

val randomUser = new User()

var index = Random.nextInt(users.length)

var randomuser = users(index)

var randomNumber = Random.nextInt();

var counter = Random.nextInt().toString()

var finalUser = randomuser.concat(counter)

var randomEmail = mails(index)

var finalmail = randomEmail.concat(counter)

randomUser.email = randomEmail

randomUser.password = “123456”

randomUser.username = randomuser

val json= new Gson

val userJson=json.toJson(randomUser)

return userJson

}

Above is the code I wrote to performance test API on GCP VM.

build.gradle:

apply plugin: ‘java’

apply plugin: ‘scala’

repositories {

jcenter()

}

dependencies {

testCompile(‘io.gatling.highcharts:gatling-charts-highcharts:2.3.0’)

compile group: ‘com.google.code.gson’, name: ‘gson’, version: ‘2.8.5’

implementation ‘com.google.guava:guava:23.0’

testImplementation ‘junit:junit:4.12’

}

task testLoad(type: JavaExec) {

description = ‘Test load the gaming api’

group = ‘Load Test’

classpath = project.sourceSets.test.runtimeClasspath

jvmArgs = [

“-Dgatling.core.directory.binaries=${sourceSets.test.output.classesDir.toString()}”,

“-Dlogback.configurationFile=${logbackGatlingConfig()}”

]

main = ‘io.gatling.app.Gatling’

args = [

‘–simulation’, ‘com.xxxx.performace.test.gatling.UserCreationSimulation’,

‘–results-folder’, “${buildDir}/gatling-results”,

‘–binaries-folder’, sourceSets.test.output.classesDir.toString()

]

}

def logbackGatlingConfig() {

return sourceSets.test.resources.find { it.name == ‘logback-gatling.xml’};

}

I am building this project and running task on one of GCP Machine

Linux test-instance 4.15.0-1018-gcp #19-Ubuntu SMP Thu Aug 16 13:38:55 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

The requested class ‘com.xxxx.performace.test.gatling.UserCreationSimulation’ can not be found in the classpath or does not extends Simulation.

can anyone guide as to how this problem can be solved.