Missing documentation.


I’m looking to read into my Java test a data file containing JSON. There is no documentation on how to read a data file only how to manually create, edit and delete. This would seem to be a notable oversight.

Please could someone provide some sample code and update the docs.



Thank you for your comments, we will improve the documentation of this topic.

In the meantime here is some sample code that might be useful:

[b]import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;

Path json_filepath = Paths.get(this.getDataPath(), "myFile.json");
String jsonStr = new String(Files.readAllBytes(json_filepath));

jsonStr will contain the entire file contents and can then be processed using a json parser. (Add any external jar file to the VU profile). Note the use of the script method getDataPath to locate the file. This is where managed data files will be held on each injector machine. These files are automatically transferred by the tool as part of the test execution process. (You can manage your own data and pass an absolute path but that is inconvenient.)

To incorporate a managed file into a test:

  1. Add file as a Data Source in the project. This is achieved by importing: Data Sources (right click) -> New Data Source->Import Data File.
  2. Bind the file to the Test: Test Level Data->Data Source Bindings