The Integration blog covers the latest in product updates, best practices, customer stories, and more.

  • September 3, 2018

How to use Asserter to create OIC Integration unit tests automatically and run them to catch regressions

Muthu Palanisamy
Senior Director, Software Development

In this blog, I'd like to show you how easy it is to use Oracle Asserter, a new feature added to Oracle Integration Cloud for creating unit tests automatically with a few clicks and run those tests to catch regressions. Asserter supports the following use cases:

  • Enable Integration Cloud users to create unit tests automatically and play them back to catch regressions when they modify their integrations (typically when they enhance an already created integration before making it production).
  • Enable Integration Cloud QA to catch product regressions as part of a new release of Integration Cloud.
  • Send Oracle a recorded instance so that Oracle can play back the instance to reproduce an issue or a bug. This is difficult without Asserter because all the dependent endpoints and third party adapters might not be available in-house to reproduce the issue. With Asserter, the endpoints are simulated and hence not needed to reproduce the issue.


Enabling Asserter

Let's assume that you have built an integration which runs as per your requirements and you have completed all your manual testing. Now you are ready to go production. At this point, you might want to create a Asserter Test and want to check that into your source repository. This is so that when you want to change that integration later, you can rely on the Asserter test to catch regressions. Regression in this case is an assertion failing because the response you're sending to the client has changed due to a bug that was introduced in a mapping as an example.

Enable the Asserter with below steps:

  • A feature flag has to be enabled in OIC to enable Oracle Asserter. To turn on the feature flag, open a Service Request with Oracle support.
  • Once the feature flag is enabled, login as a developer.
  • From the list of integrations displayed in the integrations page, click the inline menu for the integration and click Oracle Asserter -> Enable Asserter Recording 
  • You can also enable Asserter as part of the Activation as well.


Creating a test using Asserter

After the Asserter is enabled, you can create a test for a given integration using the below steps:

  • Run your integration once. That's it. Your Asserter Test (also called as Recording) is created now.
  • To check the recording, go to Oracle Asserter -> Recordings and you can see the recording is displayed. The last one created will be displayed first.
  • You can create up to 5 recordings for a specific integration.
  • Note that a given integration can take multiple path or branches depending on certain values in your input payload. So you might want to create multiple recordings by sending different input values. You can identify each recording using the Primary Identifier column.


Exporting and Importing a test 

After a recording is created, you can export and import a test for a given integration using the below steps:

  • Login as a developer.
  • From the list of integrations displayed in the integrations page, click the inline menu for theintegration and click Export
  • Check the box that says Include Asserter Recordings.
  • To import a recording click the button at the top right that says Import.
  • Select the integration archive file (.iar) and check the box that says Include Asserter Recordings.

Playing back a recording

After a recording is created, you can playback a recording for a given integration using the below steps:

  • Go to Oracle Asserter -> Recordings and identify the recording from the list that you want to playback.
  • Click the playback button. You will see the following message displayed in the banner:
  • "Successfully invoked playback for recording RecordName_7. Please refer Track Instances page to view the Asserter instance details."
  • At this point, the recording is played back asynchronously and follow the next section to check the status of the test run

 Checking the test status

After a given Asserter recording is played back, you can check the test status using the below steps:

  • Go to Monitoring -> Tracking.
  • Identify the Asserter instance from the list of runs. To differentiate the Asserter run, you can see Asserter Instancetagged at the top as displayed in the image.
  • You will also see the Test status displayed at the top as well.
  • In order to see the details of the assertion, you can click Oracle Asserter Result from the top right inline menu. This will display the golden input that was stored earlier as part of the recording which was compared against the actual response. If there is a match, the test will pass else the test will fail. Note that this will be a XML comparison and not a string comparison so that the prefix differences are ignored.

Using REST API to automate Asserter

Asserter supports REST API so that you can automate some of the Asserter operations. The commonly used REST operation will be to playback a Asserter recording. For detailed information, you can check Asserter user guide. Some of the operations supported via REST are 

  • Activate an Integration with recording mode.
  • Enable/Disable Oracle Asserter Recording mode
  • Import (with and without recordings, both integration and package)
  • Export (with and without recordings)
  • Play back a recorded instance
  • Update a recording
  • Delete a recording
  • Get Asserter Recordings
  • Submit recordings

Join the discussion

Comments ( 3 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.