Let's consider a scenario, we have to run the performance test for "create an account api" which takes input as header/path param "Auth token" and input data like user account name . So for above scenario we have 2 feature file as,
to run performance test for POST http://baseUrl/auth_param/create/input_data 1. One feature(e.g: generateAuth.feature) file which will have the auth token 2. Second feature(createAccount.feature) file which take parameter as a auth token, input data.
Here is my simulation class,
class <MyClass> extends Simulation {
before {
println("Simulation is about to start!")
}
val generateAuthTest = scenario("generateAuth").exec(karateFeature("classpath:path/generateAuth.feature"))
val createAccountTest = scenario("test").exec(karateFeature("classpath:path/createAccount.feature"))
setUp(
createAccountTest.inject(rampUsers(1) over (10 seconds))).maxDuration(1 minutes)
after {
println("Simulation is finished!")
}
}
Here, can i read auth from generateAuth.feature file which is input for createAccount.feature file, so that i can pass as a parameter? Please suggest me how to pass parameters to createAccount.feature while calling in karateFeature method.
Let me put a requirement here,
let's say we have some feature files for CRUD operations on a particular data. Here how i go to write functional scenario,
- I will create new feature file to write a scenario
- just use CRUD files to test a SINGLE flow.
Now if i go for Performance test cases on individual operation, i feel there are 2 ways,
- Create new 4 performance test feature files (one for each CRUD method) and call these CRUD feature files in the respective test feature file. Finally we just call test feature files in the respective gatling simulation class. **(In this case, I will end up with creating more test feature files as well simulation classes for performance, which I want to avoid) **
- Just call CRUD files in the respective gatling simulation class and pass the required parameters to them.(In this case , we just need to create only 4 simulation classes and run them on the basic of operation like create,read,delete and so on)
Here just wanted to know 2nd way of performance test, is it achievable or not in karate and if yes please let me know how?
Summary- I think its achievable using 3rd feature file (extra) for individual use case but I do not want to make an extra feature file for each case so that I can avoid maintenance work and can take advantage of re-usability of existing feature file from functional test to performance test.