Generating Functional Test Cases
This chapter will explain the Functional Test Cases and discuss how to generate them for following types of applications.
- Local Applications
- Server / Web Applications
Ordinary Test Cases versus Functional Test Cases
Ordinary test cases perform static analysis of source code to determine parameter values to be passed to underlying method. They also pass combination of other values as parameter. On the other hand Functional Test Cases pass the recorded values as parameters. It is necessary to perform recording in order to generate functional test cases.
Object depth
Since a functional test case needs to produce exactly same parameter values as they were recorded, it captures values of every parameter object and the object on which the method was invoked during recording. In order to capture complete state of these objects, it needs to capture state of all the objects reachable from those objects. In some cases the total number of objects a test case ends up capturing could be large and so will be the size of the generated test case code.
The object depth specified in project properties determines how deep it should go to capture the objects state.
Generating Test Cases
You can invoke the Functional Test Case Generation Dialog through the menu bar or tool bar.
Menu bar: Project -> Unit Test -> : Generate Functional Test Cases
Tool bar: Using tool button Generate Functional Test Cases
Local Applications
- Select the methods for which Functional Test Cases
needs to be generated.
- Click Start Recording. This will launch the application using the Main class provided in
Target tab of Project Properties Dialog. Each time any of the selected method is invoked during
this run, the parameter values will be recorded.
- Once recording is done, click Start Generation. From the selected methods, Functional test cases will
be generated for those methods which were invoked during recording.
Server / Web Applications
- Select the methods for which Functional Test Cases needs
to be generated..
- Perform Browser recording by clicking Start Recording. Recording requires that the server be
started passing command line arguments - -Xdebug -Xrunjdwp:transport=dt_socket,address=8680. 8680 is
the port used by default, you may pass any port provided the same port is specified in the Project Properties
at Target->AppServer Settings->Debug port. If the server is already running and was not started with these
arguments, appropriate message will be displayed. If the server is Tomcat server, then you only need to stop and
restart the server using Start Server, otherwise you will need to restart the server passing necessary command line arguments. Each time any of the selected method is invoked during
this recording session, the parameter values will be recorded.
- Once recording is done, click Start Generation. From the selected methods, Functional test cases will
be generated for those methods which were invoked during recording.