Hello,
I have been using Cactus to test JSPs for sometime now. What I had been doing
is that I set some session attributes in the testXXX case and then redirect to
the JSP, get back the results in endXXX and then assert for the expected
results and table values using HttpUnit, thanks to the integration of
Cactus-HttpUnit software.
Now can I anyway automate the process ? Let me go into this in detail. Lets
say I have an XML file having my own custom DTD that allows me to do the
following:
1) Set request parameters.
2) Set various session objects and values
3) Assign some expected values for the given set of request parameters, session
objects etc and then assert for these values.
say an example could be,
<testcase context="emp" file="getrecords.jsp">
<testcasesequence>
<request>
<param name="abcd" value="abcd_val" />
</request>
<session>
<object type="java.lang.Integer" value="16" />
<object type="EmpContext">
<field name="f1" value="vf1" />
<field name="f2" value="vf2" />
</object>
</session>
<response>
<table numbers="3" />
</response>
</testcasesequence>
</testcase>
Now this sequence says that for a given JSP file in a particular context ( as
referred to by the attributes ), we write lot of test-cases, in the form of XML
tags.
Each test-case would have - request, session, response children tags. A
request would have param children tag. Session will have the number of objects
that are to be used as the setAttribute( "name" , "value" ) . A Response (
HttpUnit WebResponse has got a great API to be manipulated . Let;s take that as
a reference ) . Now the response should have 3 tables.
Similar to this, there could be a great number of test cases available for a
given JSP file only. Now how would I automate the entire process ? I just need
to write the XML file and a single piece of code and run the tests. At the end
of the tests I should get that test-sequence 1,2 passed and test-sequence 3
failed. How would I do this with Cactus ? If not, can this one be integrated
with Cactus ?
Please Let me know your comment, suggestions.
Thanks.
Karthik Kumar.
__________________________________________________
Do You Yahoo!?
Listen to your Yahoo! Mail messages from any phone.
http://phone.yahoo.com