SolexWeb Application Testing with Eclipse |
|
|
|
Solex is a Web application testing
tool built as a plug-in for the Eclipse IDE. It provides
functions to record a client session, adjust it according to
various parameters and replay it later typically in order to
ensure non regression of the application's behaviour (with
stress testing capabilities being added at a later stage).
By recording, we mean that Solex acts as an HTTP proxy and
records all HTTP requests and responses going through the wire
between a Web client (eg. a Web browser) and a Web server. The
task of replaying a scenario consists in sending the previously
recorded and eventually customized HTTP requests to the server
and asserts each response.
Solex works with the last Eclipse 2.1 Release, Build id: 200303272130.
Solex started as an internal project because we were unable to find an open source testing tool fully suitable to our needs and in particular capable of dynamically altering requests. Furthermore, the tool was expected to be fully integrated with our internal development environment based on the Eclipse platform.
For some web applications, a
request depends on a previous server's response. To address
such a requirement, Solex introduces the concept of
extraction and replacement rules. An extraction
rule tied to an HTTP message content will bind a value with a
variable. A replacement rule will replace any part of an HTTP
message with a variable content.
Solex therefore provides an easy way to extract URL parameters,
Header values or any part of a request or a response, bind
their values with variables and then replace URL parameters,
Header values or any part of a request with the variable
content.
Example:
Let's imagine the next two requests recorded from a Web browser:
Replaying these two requests without any modification may fail because dynamic_id must be different each time. This value may come from the first response body content. By using Solex, it is possible to add an extraction rule to the first response (e.g. obtaining the value 12345) and a replacement rule to the second request (e.g. populating the dynamic_id parameter with the value extracted).
Moreover, Solex provides the user with the capability to add assertions for each response. Once a response has been received, all assertions of this response will be called to ensure that it is valid. If not, the playback process is stopped.
Solex provides several kind of rules and assertions, the most complicated ones support regular expressions.
The easiest way to see the Solex components is to open the dedicated Solex perspective which supplies an Editor and two View. All ".slx" extension files opened from Eclipse will invoke the Solex editor. The Playback Results view displays requests and responses sent and received during the playback process. It also displays all variables created during the process.
We will start by recording an HTTP session from a Web browser. First, set the port you want to be used by the integrated proxy.
Open the Eclipse preferences pages and set any free port, eg. 8088. The host field is not used to record a session, it will be used later to run the scenario back.
Then, tell your browser to use a Web proxy. Proxy Address (also called proxy server) is the computer where Solex is running and Proxy Port is the value you selected previously. The sample picture below is taken from Microsoft Internet Explorer™.
Create a new Solex session file (.slx) by using the standard Eclipse New File menu entry.
The new session is empty and ready to receive requests and responses.
Start the Solex recording process from the Eclipse toolbar or the Solex menu. You can now navigate through the Web application you want to test, and the Solex editor will record and simultaneously display the related HTTP messages.
Stop recording once your session is terminated. Use the Eclipse toolbar or the Solex menu to do this.
All requests may be expanded to see their content.
It is time to add rules and assertions to this session by using the contextual menu (right button click on your mouse) on the desired items.
In this example, the session we recorded just calls the google.com web site, then searches the web site of the solex project and opens it ..
We first extract the value of the URL "q" parameter. The value is: "solex". We bind the value with the "P1" variable.
We also want to assert the response by testing if the HTML <title> tag exists and contains "Web Application Testing with Eclipse ", And it doesn't contain the sentence "Not for Eclipse".
Open the assertion dialog box. The Preview button computes the regular expression and returns true if the regular expression produces a token contained in the response.
Notice that the activated checkbox allows to assert against the existence or not of the regular expression,i.e: if you want to assert that your regular expression doesn't exist in the body, write your regular expression (ex: 'Not for Eclipse') and check 'N' in the first checkbox above.
You can also assert with a variable: Open the assertion dialog box again, and select 'N' in the appearence checkbox and the variable solex extracted below in the variables checkbox.
The regular expression contained in the variable is displayed.
Next, we are ready to use the "P1" variable in another request. We do that in the next request by replacing the URL "parameter2" parameter that we add by clicking on the entry 'Add a new parameter' of the contextual menu of the URL, with the variable's value. We add a replacement rule to the "parameter2" entry and use the "P1" variable.
We have also added an extraction rule to the response in order to extract a complexe value by using a regular expression as it shown below,"solex" is the variable name that handles the value extracted. Here ,the compute button computes and displays the value found in the data originally recorded.
This time, the rules are added from the Message body content dedicated view by using of the two buttons located at the top right position of this window. The way to create a regular expression rule is the same for both extraction or replacement methods.
This can be done by simply opening the rule related dialog box and editing a regular expression or first by selecting any part of the body content and then opening the rule related dialog box.
When selecting a body part, it is assumed that you select the first delimiter of the token to extract or replace, the token itself and the last delimiter. Both first and last delimiters may be empty.
The string: '<title>Solex - Web Application Testing with Eclipse</title>' selected contains the first delimiter and the token we want to bind to a variable.
Then, as we selected a part, the Helper section is enabled and provides you the ability to select now the token. The Generate button will then compute a regular expression returning the token.
At last, we run the session. The target host can be configured in the preferences. If you don't supply one, the host used for recording will be taken. Two buttons are supplied, the first one plays one request at a time and the second one plays all requests. The Playback Results view displays a summary of each request sent, its response status code and all variables created.
An export button located on the upper right corner of the Playback Results view allows you to export results as XML.
$Id: solex.html,v 1.7 2003/04/10 13:32:35 cv Exp $