Generating Test Cases
In this chapter we will discuss how to generate Test Cases for following types of applications.
- Local Applications
- Server / Web Applications
Generating Test Cases
You can invoke the Test Case Generation Wizard through the menu bar or tool bar.
Menu bar: Project -> Generate Test Cases
Tool bar: Using tool button Generate Test Cases
Local Applications
The Test Generation Wizard takes a step by step approach to generation of test cases.
Details of each step are provided at the top of the step.
- Generating Test Classes for Java Files:
Test classes are generated for Java source files, before actually generating the test classes
Unit Test will generate required objects by parsing the source code and will add those objects to
object repository. Then it will generate dummy test classes and will execute them after that will
collect the results of execution and based on that will generate the final test classes.
Server / Web Applications
A Server Project contains both Java and JSP files.
AppPerfect uses the HtmlUnit framework to record and execute unit tests for
server projects. Server projects differ from local projects in many ways:
- Server projects unit test the target application via HTTP, local
projects are unit tested directly via Java calls.
- Server project unit tests are generated by recording your interaction
with your target application via a Web browser. Recording is performed using Proxy Recording feature. All traffic between your
Web browser and the target application is recorded, analyzed, and
appropriate test cases generated. For local projects, your Java source
code is directly parsed, analyzed and appropriate Java test classes
created.
- Special features such as "in-container" testing is supported for server
projects, but not for local projects.
The Test Generation Wizard takes a step by step approach to generation of
test cases. Details of each step are provided at the top of the step.
- Getting mapping information for JSP files:
You will be able to see the
list of JSP files in a table with 'Mapped File Name' as a field. For
Struts application types, there will be a drop down box in this field
from which you select the mapping extension. For a template based
application, this field is editable and you should provide the mapping
yourself. The check boxes against each JSP name name will indicate
whether or not that page has been visited during recording. Test cases
are generated only for pages that are visited during recording. Click the
'Record Test' button to start recording. You can
pause recording and navigate to the desired pages if required. Then click
'Resume' to start recording again. Click the 'Stop' button to stop
recording. The JSPs visited can now be seen with a check mark in the
'Page Visited' field.
- Generating Test Classes for Java/JSP Files:
First, test classes are generated for Java source files, if any, in your
server project. Then unit tests are created for all the JSP files that have been
recorded.
The process of Test Class Generation also generates the Object Repository
for your project.
Next step is to run the test.