Creating component tests for a Web service

To test a Web service component, the best approach is to submit a series of requests to the server and to ensure compliance of the return messages with the corresponding expected values.

Before you can create a Web service component test, have access to the Web service definition file (WSDL).

To create a component test for a Web service:

  1. Select File > New > Other > Component Test > Web Services > Web Service Component Test and click Next.

    This starts the Create Web Service Component Test wizard.

  2. From the first wizard page, select the test project that will contain the test, or click New to create a new test project, and click Next.

  3. On the next page, you select the Web service under test:

    1. Locate the WSDL definition file for the Web service under test. You can use Browse for a WSDL from your workspace, or use Import to import the file from the filesystem.

    2. Select one or several port types to test.

    3. In the Web service runtime Java proxy generation list, select the runtime (IBM WebSphere or Apache Axis) that you want to use to generate the Java proxy for the test.

      Note: You cannot use multiple runtimes within a single project. If a Web service component test or stub already exists in the current test project, you can only use the runtime that was previously used in this test project. To create a test using a different runtime, create a new test project.

    4. Click Next.

  4. On the Define a test scenario page, create the test scenario by selecting the port locators and operations that you want to test.

    1. Add one or several instances of the port by selecting a port locator from the list and clicking Add. (You can also double-click a port locator to add it to the scenario.)

    2. To assign a meaningful name to the port, select the instance from the test scenario, click Rename, type the new name, and click OK.

    3. Double-click each operation to be included in the scenario.

    4. When you are finished building the scenario, click Finish.
    The result is a new test suite along with a test behavior script and one test case for each selected port locator.

You can now edit the test behavior script generated from the WSDL file. Use the test data table to specify input values (server requests) and expected return values. You can also add, remove, and edit initialization points and validation actions for the test. Before running the test, make sure that the Web service under test is running on an application server.

 

Related concepts

Test strategies

 

Related tasks

Creating a Web service stub