Using JMeter I have been trying to produce a CSV of the ID of all the database IDs that my web app creates. I'm simply looking to save one column of strings without any spaces, however when I do that I get inconsistent outcomes in the CSV file. Sometimes there are skipped lines and sometimes there are no skipped lines. I have tried working on this with JSR223 and Flexible File Writer but both give the same result, always the same issue. I thought there was whitespace or a line break in my variable but the debug listener indicates that is not the case (also when I remove the '\n' character from Flexible File Writer the entire output prints to a single line, so I think there are no line breaks present)
2 Answers
I solved this one just there now myself. Turns out I was setting the listener to listen to some other samplers in my test plan instead of just a single one, those samplers didn't have the ID property in a JSON response, so they output blank results, leading to blank lines being output. Solved, hope this can be of help to someone else in future :)
Probably it's somehow connected with scoping rules, either your JSON Extractor tries to fetch a variable from another Sampler or Flexible File Writer is listening to another Sampler when the variable is not set yet.
Make both direct children of the Sampler which produces this id
and it should resolve your issue.
Alternatively add a Debug Sampler or Debug PostProcessor and see what are createdRecordID
variable values for each step of your test using View Results Tree listener, most probably there is a blank value somewhere.
-
Yes, that was the issue, the penny dropped about 30 mins ago for me. Thanks for the help tho :)– hydroxyCommented Dec 19, 2022 at 15:47