Azure Load test preview unable to read data from parameterized CSV file in JSR223 Sampler

258 Views Asked by At

I used JSR223 Preprocessor to create the request body for a POST JSON request. I used Groovy language for it The code has some parameterization so, I mentioned the path for CSV file in the script as below and attached the Order.csv file to the test plan in load test preview.

CSV file path in the script: "List lines = new File("Order.csv").readLines()"

So whenever I run the test in Azure load test preview, the is the error message im encountering:

javax.script.ScriptException: java.io.FileNotFoundException: Order.csv (No such file or directory)

How can I fix this. Please Help.

I tried just mentioning the CSV file name in the code and attached the CSV file to the Load test preview along with .jmx file.

This is throwing error saying, File not found

1

There are 1 best solutions below

0
On

How do you know where guys from Microsoft are placing the CSV file and why do you expect them to copy it to the same place where the .jmx script lives?

I would suggest amending your Groovy script to get the file location dynamically using FileServer class, i.e. change this line:

List lines = new File("Order.csv").readLines()

to something like:

List lines = new File(org.apache.jmeter.services.FileServer.getFileServer().getBaseDir() + File.separator + 'Order.csv').readLines()

More information on Groovy scripting in JMeter: Apache Groovy: What Is Groovy Used For?