I am using jmeter 5.3 and I got my jmeter test, that uses data from pre-created JSON file. I would like to let jmeter to create this file before every test run. This includes:
- open existing JSON file
- update certain values in this file
- save and close the file
- run the batch file
- run the test
that first 4 steps should be executed just once, even I run test for more users. ( I suppose I could use extra thread for that)
I tried to use this sort of code, but it doesn't work.
import groovy.json.JsonSlurper
def jsonSlurper = new JsonSlurper("cfg.json")
def taps_count = jsonSlurper.context.parameters.find { "globals" }
taps.count.value."random_taps" = 100
def period = jsonSlurper.context.parameters.find { "time_window" }
period.value."from" = "2020.12.14 08:40:00"
period.value."to" = "2020.12.14 08:45:00"
"script.bat".execute()
You need to change this line:
to this one:
This is the very first and the most obvious error, if you experience further problems you will need to provide the contents of your
cfg.json
fileMore information: