Writing Results from SilkTest Workbench
Writing a Results File from SilkTest Workbench
When running a scripted test in SilkTest Workbench the IDE provides a pass or fail indication but there are no native methods for creating a printed results file. The attached filePrint.dll will, when referenced from your VB script, enable you to create a results file that will output either a plain text file or a webpage with colour. You can add print comments to the results file in a similar fashion to the Print(), LogError() and LogWarning() statements that are available in SilkTest Classic. If you specify an HTML out put this dll also allows you to specify foreground and background colours, font name and three font styles – bold, italic and bolditalic.
Closing the results file will automatically calculate the length of time taken to run the testcase and, if required, automatically display the results file.
Finally, wherever you see the statement ‘if param(x) is specified then param(y) is required’, a blank string is an acceptable parameter e.g. for the writeFile method with HTML output
will print the word ‘data’ in blue italics on a white background using the default Arial font.
Adding the filePrint reference to the project
Copy filePrint.dll to a folder on your hard drive. A suggested place is to create a new folder in your SilkTest installation called ‘Workbench modules’; note that if you uninstall Silktest this folder will not be deleted.
You will need to add a reference to the filePrint.dll in your Workbench project to enable usage of the class libraries.
1. From the Workbench script IDE select the ‘Properties’ tab.
2. Right-click on ‘References’ and select ‘Add Reference’
3. ‘Browse’ to wherever you have placed filePrint.dll and select it
4. Click ‘Open’
5. Click ‘Okay’
The class library is now ready for use.
e.g. Dim results as New filePrint.results()
param1 = name of the testcase
param2 = the path to and the name of the results file. Acceptable file suffixes are htm, html and txt.
param3 = append or new (new = overwrite if the file exists, append will create the file if it does not exist
param4 = automatically open the results file at the end of the testcase. Parameters are "yes" or "no" - default is "yes".
param6 = font size. The font size declared here affects the entire results file output. Note that the testcase name will always be printed one size larger and in bold e.g. a font size of 4 will print the testcase name at size 3/bold. Default = 2.
writeFile(param1, [optional] param2, [optional] param3, [optional] param4, [optional] param5)
param1 = the information to be printed (string input only).
param3 = the font backcolour if HTML output has been specified in openFile. Default is white.
param4 = the font typeface if HTML output has been specified in openFile. If the requested font does not exist on the system then the output will revert to the browser’s default font. This typeface only affects the current line. Default is ‘arial’.
param5 = the font style where style can be ‘bold’, ‘italic’ or ‘bolditalic’. Default is no font style. This only affects the current line.
Please note that the amber used as the background in LogWarning is a user-defined colour (#FF8420). User-defined colours can be used directly whereas the sixteen pre-defined web colours have to be passed as a string. Suppose you had generic string variables called 'forecolour' and 'backcolour'; the user-defined amber would be passed as follows:
dim forecolour as string=""
dim backcolour as string=""
You can change the forecolour without changing the backcolour as follows:
If webpage output has been specified and the elapsed time is required then start time, end time and elapsed time will all be displayed as white-on-navy. Elapsed time is calculated in milliseconds and is displayed as hours/minutes/seconds/remaining milliseconds.