Editing message-based stubs for Contract validation

When you want to use a message-based stub as part of producer-driven Contract testing, you must edit the stub that you create based on a Message Exchange Pattern (MEP) in an operation.

Before you begin

You must have completed the following tasks:

Procedure

  1. Select the stub that you created under the operation.
  2. Right-click the stub and in the menu, click Open With > Test Editor.
    The stub is displayed in the Test Editor.Image of the stub in the Test Editor

    The Message Switch and Message Case are created as the Test Steps with the configurations that you provided for the MEP.

  3. Click the Properties tab.
    The Properties tab of the stub is displayed.Image of the stub in the Test Editor
  4. Select the Include Contract Validation option.
    Note: When the Include Contract Validation option is selected, the following events occur:
    • The Send Error Response option is automatically selected. When this option is selected, the stub is forced to send a response if the incoming message fails the validation that is set.
    • The schema that is added to the messages configured for the Publish or Request MEP in the operation is automatically considered as the schema to be validated.
  5. Save the stub.

Results

You have edited the stub to validate a Contract by matching the schemas in the messages sent by a producer.

What to do next

You can perform the following tasks:
  1. Start the stub that you edited for validating the Contract.
  2. Run the test in the operation that sends messages as the producer.
  3. View in the console log, after the test runs that the incoming messages are validated against the contract.
    Note: If the validation fails, a response indicating an error in Contract validation is automatically sent to the producer.