Reputation: 11
For example function __machineName can be called from groovy:
def machineName = new org.apache.jmeter.functions.MachineName().compute()
Can anyone advise how can I call function __stringToFile in a similar way?
This function has 4 parameters: 1 - file name 2 - content 3 - append (true/false)(optional) 4 - file encoding (optional)
I would like to pass a Groovy variable (or JMeter variable) as a "content" parametr.
I need to write to a one csv file from severals threads after end of the thread loop and __StringToFile is probably the only one safe way? (prevents "race condition" during writing).
Upvotes: 1
Views: 924
Reputation: 168082
__StringToFile is probably the only one safe way?
no, it's not (unless you call it under the Critical Section Controller)
If you need to write values from multiple threads into a single file consider using either Sample Variables property or Flexible File Writer
If you're still looking for a way to write a string to file from Groovy it's as simple as:
new File('/path/to/your.file') << 'your string here'
Upvotes: 1