Creating producer-driven Contract tests by synchronizing resources

You can opt to create producer-driven Contract tests when you synchronize resources that you created in another application with Test Integrations and APIs. If you already have created tests in the other application for your system under test and you have defined schemas and roots for messages, you can use the synchronizing feature of Test Integrations and APIs to generate Contract tests and stubs that you can run on Test Integrations and APIs.

Before you begin

You must have completed the following tasks:
  • Created tests for your system under test in another application. The tests must include messages that use a transport and you must have defined schemas and roots for the messages.
  • Read the types of resources that you can synchronize with Test Integrations and APIs. See Adding a resource.
  • Created a project. See Creating a project.
  • Opened the Synchronization view in the Architectural School perspective in Test Integrations and APIs.

Procedure

  1. Click the Create Synchronization Source icon Image of the create synchronize source icon. in the toolbar.
  2. Perform the following steps in the Create a new Synchronization Source dialog:
    Image of the create a new synchronization source wizard.
    1. Click Browse to locate the file that contains the resources to synchronize.
    2. Identify the file in the location where you saved it.
    3. Select the file, and then click Open.

      The type of the resource is automatically selected based on the resource.

    4. Enter the location of the resource in the Location field or browse to select a resource in your local system.
    5. Select or enter an environment.
    6. Click Next.
    7. Click Next in the Authorizations window.
      The Generate Assets for Operations dialog is displayed.Image of the Generate assets for operations dialog box.
  3. Perform the following steps in the Generate Assets for Operations dialog:
    1. Click Contract Tests to generate the Contract tests for operations from the resources synchronized.
      Note: The default type of tests that are created is Tests.
    2. Select the tests that you want to generate by clicking the box against each test or select the Create Tests in the header column to generate all the tests.
    3. Select the stubs that you want to generate by clicking the box against each stub or select the Create Stubs in the header column to generate all the stubs.
    4. Create Next.

      Test Integrations and APIs determines if the schemas are defined for messages in the resources and decides the number of operations, tests, and stubs that must be generated.

    5. Click Next on each of the dialog boxes that display as the test generation progresses.

      After all the tests are generated from the resources, the Summary dialog is displayed.Image of the test generation summary dialog.

    6. Click Finish.

      The Test Factory view is displayed that shows all the operations created from the resources synchronized. The tests are created under operations.

Results

You have successfully created producer-driven Contract tests and stubs under operations from the synchronized resources.

What to do next

Verify the properties of the generated stub by performing the following steps:
  1. Open the project in the Test Factory view.
  2. Right-click the stub and in the menu, click Open With > Test Editor.
  3. Click the Properties tab.

    If the Include Contract Validation option is selected, then the stub is part of the producer-driven Contract test.