Extent Badboy to write a CSV-Logfile by using a JScript Tool Element
- Create a variable called "logfile" and set it's value to the name of the desired logfile, e.g. mylogfile.csv. (You can also define it with a path like "c:
- Create a test file called "logentry.js" and place it in the same directory as your test. The content of the file is the script shown at the end of this blog entry.
- Add a "JScript Tool" to your testplan at the points where you want to write a timestamp into the logfile, select checkbox "Allow Access to Plugin Priviliges" and set the source to to the formerly created "logentry.js" file. (You can reference the script file with absolute or relative pathes. If you go for relative ones, the whole test can be simply transferred to other machines)
That's it! You can copy that element to all that points in your test, where you want to log a line. The logline will contain the host-Variable as well as the parent steps name and the name you gave to the JSctipt tool element.
var datumzeit = new Date();
var stepname = badboy.script.find(badboy.current).parent.get('name');
var value = '"' + badboy.getVariable('host') + '","' + stepname + '","' + badboy.script.find(badboy.current).get('name') + '","' + datumzeit.toUTCString() + '","' + datumzeit.getTime() + '"' + " rn";
var fso = badboy.plugin.createObject("Scripting.FileSystemObject");
var textFile = fso.OpenTextFile( badboy.getVariable('logfile') + '-' + badboy.getVariable('host') + '.csv', 8, true);