0
votes

I have a CSV file on a location from which i am reading the contents in a file. Thats why i have added Jmeter Bean shell Post processor and checking values of variable in debug sampler.

There is no error coming in sccript and thread is successfully getting executed and values are properly coming in variable. Hiwever, in Jmeter logs, i am getting error -

ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval In file: inline evaluation of: ``Location,Advertiser,Product,Campaign,Supplier,Insertion order ID,Invoice number, . . . '' Encountered "," at line 1, column 9.

I am having below code in my BeanShell PostProcessor -

${__FileToString(${InvoiceDataFile},UTF-8,CheckInvoice)}

${InvoiceDataFile} is a variable which i defined in the user defined variable and its value is the path of the directory where my CSV file is present.

eg: ${__P(includecontroller.prefix)}/Reporting/Prisma/Prisma US/properties/ReportsVerificationUS-${__P(test.environment)}/invoice_report.csv

Please suggest.

Regards.

1

1 Answers

2
votes

Don't inline JMeter Variables like ${InvoiceDataFile} or functions into Beanshell script body, they may resolve into something which will cause syntax errors. The correct Beanshell equivalent function will look like:

vars.put("CheckInvoice", org.apache.commons.io.FileUtils.readFileToString(new File(vars.get("InvoiceDataFile")),"UTF-8"));

Going forward you can take the next steps in order to get to the bottom of your Beanshell script failure:

  1. Add debug(); directive at the beginning of your script. This way you will be able to see debugging output in STDOUT
  2. Put your code inside try block like

    try {
       //your code here
    }
    catch (Throwable ex) {
       log.error("Failed in Beanshell", ex);
       throw ex;
    }
    

    This way you will see a "good" error stacktrace in the jmeter.log file.

See How to Use BeanShell: JMeter's Favorite Built-in Component for more information on Beanshell scripting in JMeter