Stubs made easier with Rational Integration Tester
Simplify integration testing — even if you don't have all the necessary components
Stubs made easier with Rational Integration Tester
Integration testing means testing a user application across all components and service boundaries. Doing so, however, is not always easy.
Some components of the system might not be unavailable — perhaps a particular service is still in development. Services might be in use by others and can't be shared, or might be expensive to use. Opening up access to other services might expose private data to testers, and so those services aren't available to the test team.
If you stub out the system components, you can test that system without waiting for components to become available. However, testers traditionally have relied on developers to create these stubs. Usually the stubs aren't user-friendly, and there's little chance that you can reuse them. Additionally, maintenance is normally handled by the developers.
IBM® Rational® Integration Tester (part of IBM® Rational® Test Workbench) is a desktop solution designed to address the challenges of testing legacy or modern architectures by helping you:
- Visualize the connections and dependencies between services and components to plan an integration test strategy
- Stub out services that are unavailable for testing, making continuous integration testing possible and reducing the risk of errors in the application
- Automate all aspects of integration testing
How integration testing works with Rational Integration Tester
The following steps detail how you can easily create stubs for integration testing using Rational Integration Tester.
Configuring Library Manager
Rational Integration Tester supports a wide variety of technologies — such as web services and email — out of the box. However, external libraries (or Java JAR files) are required for proprietary technologies. These libraries are supplied with the installation files of that software. Library Manager, the main configuration tool for Rational Integration Tester, helps you manage these supported technologies.
To configure libraries that are required to conduct a test, open Library Manager and from the Database (JDBC) tab:
- Select IBM DB2 9.7 from the Providers section.
- Browse to the Installation Directory, as shown in Figure 1:
Figure 1. Configure Library Manager for IBM DB2
This demonstration uses sample WSDL for adding numbers, which does not require any specific Library Manager settings.
After you have configured the required libraries, you are ready to work on a Rational Integration Tester project.
Create a new project
A project is like a user workbench where you can create tests and stubs and execute them. Creating a project has three steps:
- Setting up a name and location
- Connecting to the project database
- Setting up a user-based permission
Steps 2 and 3 are optional, although step 2 is recommended because you can record and view test results. Here I've created a project with database MySQl – projectdb (assuming that the project database projectdb is created using MySQL).
From the Rational Integration Tester Welcome page, click New Project – Set name and location and navigate with the Next button until you reach the Server Settings screen of the Create New Project wizard. Choose these server settings:
- Database provider: MySQL
- Database URL: jdbc:mysql://localhost:3306/projectdb
- Username: root
- Password: your database password
When these steps are completed, click Finish, as shown in Figure 3:
Figure 2. Create New Project details
After you create your project, you can create your test environment using the workbench. Note the Perspectives toolbar, which has six perspectives. See Figure 3:
Figure 3. Workbench layout
Figure 4 shows the six perspectives with a description of each:
Figure 4. Six perspectives
Create the test environment
A test environment is a set of runtime configuration settings that tests resources. To create the test environment, select Project from the Rational Integration Tester workbench and click Create New Environment. Figure 5 shows the Create New Environment wizard. Specify the name for the environment — for this example, use demo— and click OK.
Figure 5. The Create New Environment wizard
Build the model system for testing
To build the model system for testing, you first want to add new Web Services Description Language (WSDL). For this demonstration, I'm using sample WSDL add numbers. Assume the service is started at location http://localhost:8088/addNumbers?wsdl. To invoke the new WSDL wizard, follow these steps:
Right-click in the logical view to New > Web > WSDL > Wizard. See Figure 6:
Figure 6. Invoke the add new WSDL wizard
The wizard to add new WSDL appears. Click New. See Figure 7:
Figure 7. Configure the WSDL dialog
On the New WSDL wizard, click Change. See Figure 8:
Figure 8. Browse to new WSDL location dialog
In the Select Location wizard, click the URL tab. In the URL field, type: http://localhost:8088/addNumbers?wsdl. Click OK. See Figure 9:
Figure 9. The Select WSDL location dialog
Now the addNumbers WSDL is added in the wizard. Click Next. See Figure 10:
Figure 10. Configured WSDL dialog
Now you can either create a new service component or select an existing component. For this demonstration, you want to create a new component, so proceed with the default choice Create a new Component. Click Next. See Figure 11:
Figure 11. Create a new Component dialog
The next wizard asks you if you want to create a new environment or choose an existing one. As Figure 12 shows, you've already created the environment for the project and named it demo. Continue by clicking Next:
Figure 12. Configure with the Environment dialog
Figure 13 shows the next set of options. Select Open Synchronization View and perform the synchronization. Click Finish to complete the WSDL synchronization.
Figure 13. The Synchronization options dialog
Click the Schema Library tab. Figure 14 shows the WSDL schema:
Figure 14. Schema Library
The WSDL is synchronized. Click on the Logical View tab to see it updated with the system modeled, as Figure 15 shows:
Figure 15. System modeled view
Create the new test
You can create tests in the Test Factory perspective. Switch to the Test Factory perspective. Then:
- Invoke Test using the message exchange pattern (MEP) window.
- Right-click on the addition operation and select New > Tests > Test using MEP.
Send Request and Receive Reply actions are added to the test. See Figure 16:
Figure 16. Edit the Send Request
You can modify Send Request and Receive Reply actions with tags, or variables. Tags provide runtime configuration settings to test resources and are used to pass information within Rational Integration Tester.
The current test is modified for input values. See Figure 17:
Figure 17. Edit Receive Reply
Save and execute the test
Now you're ready to save the test you created. To do so:
- Right-click the test to get the menu options.
- Select Run.
- Check to see if the test passes.
When the test passes, you'll see the Execution Result dialog displayed, as shown in Figure 18:
Figure 18. Execution Result for test
Create stubs for the service
Stubs simulate services that are unavailable. One way to create a stub is by using the MEP window. First select the operation for which you want the stub in the Test Factory perspective — in this case, the addition operation. Right-click addition, then select New > Stubs > Stub using MEP.
The definition of the MEP for the addition operation is based on the information in the WSDL file. The stub details are shown in Figure 19:
Figure 19. Edit the stub
Rational Integration Tester provides elements to tests and stubs such as decision points, loops, and calls to other tests or external processes — even SQL calls to databases. All these elements can be added through the GUI without any coding required.
Save and execute the stub
To make sure the stub has replaced the service, stop addition service if it's running. You can make sure it has stopped by executing the addition test you created. The test fails if the service isn't running, as shown in Figure 20:
Figure 20. Execution test with failed results
Now execute the stub:
- Right-click on the stub you created to see the menu options.
- Select Run.
- Check that the status of the stub in right panel is Ready.
- Execute the addition test again.
The test should pass this time, as shown in the Figure 21:
Figure 21. Execution test with passed results
If the stub must be reused by other team members, it can be published to the IBM® Rational® Test Control Panel using IBM® Rational® Test Virtualization Server.
Building and maintaining service stubs is easy with Rational Integration Tester, because it doesn't require any coding skills and ensures maximum reuse. Rational Integration Tester helps in three key ways:
- You can continue testing when services aren't available.
- You can test earlier and more often, reducing the cost of defects.
- You can force behaviour in the system under test by controlling the services (or, more specifically, the responses from those services).
- Find out more about Rational Test Workbench.
- Stay current with developerWorks technical events and webcasts focused on a variety of IBM products and IT industry topics.
- Improve skills. Check the Rational training and certification catalog, which includes many types of courses on a wide range of topics. User can take some of them anywhere, anytime, and many of the Getting Started ones are free.
- Download Rational Test Workbench, which includes Rational Integration Tester, from Passport Advantage. Registration and sales representative assistance required for access to 30-day free trial.
- Download a free trial version of Rational software.
- Evaluate other IBM software in the way that suits best: Download it for a trial, try it online, use it in a cloud environment, or spend a few hours in the SOA Sandbox learning how to implement service-oriented architecture efficiently.