Loading Filesby Group Public on Saturday February 06 2010 @ 10:56:15 (1/1 Points) |
|
| API ↪Reference ✑ Reply ✓ Stick It ✗ Ditch It ⚐ Tag It |
There are many needs to have blocks of text used for testing. One option for small text is a heredoc→, or you could load text from a file. This document gives a few options for loading text from a file.
textFile
This is the simplest function as it simply loads a unicode file into a string.
set %Data% as textFile File.txt
The file is expected to be a unicode encoded file, either UTF-8 or UTF-16.
readTextFile
This function allows you to load a text file with an arbitrary encoding.
set %Data% as readTextFile File.txt with %Encoding% iso-8859-1 end
If called without specifying an encoding the standard Unicode loading, as in textFile will be used.
Directory
The above examples assumed that the file you wish to load was in the script path→. If instead your file is relative to the current .test you'll need a way to locate it. In this case you can use the %This:Dir% context→ item.
set %Data% as readTextFile %This:Dir%/File.txt
This will then attempt to load the file from the directory in which the current test unit resides.
TestPlan Loading Files
