During a load test, I have a requirement to output dynamic values used for the virtual user instances to a separate file. How do I get Neoload to send these values during a test to an external file for review later?
During your load test, you may need to log some information related to your script. This is helpful if you want to check afterwards the data used or modified during your load test.
There are 2 ways for logging information during your tests:
Note: The logging level can be configured in the project settings in the Runtime parameters section.
var lock = new java.util.concurrent.locks.ReentrantLock();
var date = context.variableManager.getValue("CurrentDate");
context.fail("Variable 'CurrentDate' not found");
var writer = new java.io.FileWriter("c:\\log.txt",true); writer.write(date+";"+context.currentVU.id+";"+text); writer.write("\r\n");
Note: if you use it inside the JS librairie, copy all the code inside the function otherwise the compilation won't work. If you use all the code inside a NeoLoad JS you can leave it as is.
Pre-requisite: "CurrentDate" is a Neoload variable (see Variable manager to create it) that will display the current date. It's optional.
Note: "context.currentVU.id" will display the instance of the vu, it's also optional.
var cpt = context.variableManager.getValue("StringRandom");
context.fail("Variable 'StringRandom' not found");
writeFile(cpt+";was the value from my test");
Note: "StringRandom" is a Neoload variable, it's optional.