Creating an HTTP server in a testby Group Public on Monday March 15 2010 @ 08:30:33 (1/1 Points) |
|
| API ↪Reference ✑ Reply ✓ Stick It ✗ Ditch It ⚐ Tag It |
There are several cases when testing where the program being automated expects a URL to be provided, or when a live document is required. TestPlan has the ability to create an HTTP server inside your test directly, and further allows you to interact with the requests.
A Basic Case
The easiest case it to simply create a static document and have it available to the program being testing. This is a basic example:
call unit.server.http.AddFile with
%Content% <<<EOF
<html>
<body>
<p id='firstid'>Hello</p>
</body>
</html>
EOF
end
set %Path% %Return:URL%This will provide a URL for the simple HTML file. Note the use of heredoc→ for including a snippet. If you have a lot of content you can also load a file→ instead.
call unit.server.http.AddFile with %Content% as textFile %This:Dir%/mytest.html end
This creates a server that exists for the duration of the execution (TestPlan execution, not an individual unit). If you wish to quickly test your URL you'll need to delay exiting. Try this:
Notice %Path% Sleep 120s
Then copy the URL into a browser and you should see your content. Obviously for normal testing you won't need this sleep→ call.
TestPlan Creating an HTTP server in a test
