The runservertests task provides support for starting up a servlet container to run in-container tests, and shutting it down again after the tests have completed.
This task will perform several actions, in the following order:
testurl
attribute.
starttarget
attribute. This target is supposed to start
your container. The runservertests task will then
constantly poll the server by calling the test URL until the server
answers back.
testtarget
attribute. This target is supposed to run the unit tests. This is
usually implemented by using the Ant junit
task.
testtarget
has finished executing), it will then
call the Ant target defined by the stoptarget
attribute.
This target is supposed to stop the container. The
runservertests task will then constantly poll the
server by calling the test URL until the server stops answering, at
which point it will consider the server to be stopped. Note that the
stoptarget
will only get called if the server was not
already started when the runservertests task began
executing. This is to allow keeping running servers for intensive
debugging phases.
starttarget
, testtarget
and stoptarget
as you wish and they will get called at the
right time.
waitfor
(with the
http
condition), parallel
,
sequential
and antcall
.
Name | Description | Required |
---|---|---|
testurl | The HTTP URL to check whether the server is running. | Yes |
starttarget | The target that is called when the server needs to be started. | Yes |
stoptarget | The target that is called when the server should be shut down. | Yes |
testtarget | The target that is called once the server is running. This target will normally perform the actual unit tests. | Yes |
timeout | The timeout in seconds. If the server could not be started before the timeout is reached, the task will terminate and report a failure. | No |
start.tomcat.40
will
be called if the specified test URL is not available. After the server
has started up so that requests to the test URL return successful HTTP
status codes, the target test
is called. Finally, after the
test
target has completed, the target
stop.tomcat.40
is called to shut down the servlet
container.
<runservertests testurl="http://localhost:${test.port}/test/ServletRedirector?Cactus_Service=RUN_TEST" starttarget="start.tomcat.40" stoptarget="stop.tomcat.40" testtarget="test"/>