The Simple Way To Unlock Third-Party API Testing

cerberus-testing-the-simple-way-to-unlock-third-party-api-testing

Delivering a successful user experience is a continuous challenge. You must meet the user’s expectations while ensuring non-functional requirements such as performance, privacy, and security.

A website has on average 40 calls to external APIs for analytics, consent, and other partners services. These APIs are not optional; they are part of the user experience and therefore important to test.

Traditional test automation tooling is narrowed. You can perform functional tests on a web or mobile interface, but not API ones. On the contrary, you can test APIs but not the user interface.

In this article, we share a simple way to implement test automation for your 3rd-party APIs within a web application. We use Cerberus Testing  in three steps: 

  1. Identify your 3rd-party APIs expectations
  2. Configure your test to collect the network data
  3. Add your expectations with filters and controls

First things first, let’s start by exploring and defining your expectations.

Identify your 3rd-party APIs expectations

The first step is to know which external calls are most important to test. Ideally, you have the knowledge of the application. You can also ask the product and engineering teams about specific integrations, involving them in the initiative.

Additionally, you can identify the various 3rd-party calls just using your web browser. In Firefox, you can access various traceability elements with a right-click on “Inspect”. The data you are searching for is on the “Network” tab.

Figure 1: You can access the 3rd-party API calls in the browser.

While browsing your website, the various 3rd-party API calls will appear on that list. The important elements to note are the domain and the request. They will be necessary to define your assertions.

The next step is to retrieve these data inside your test.

Configure your test to collect the network data

Accessing the browser and network traffic data is not trivial. If you have your own test automation framework, a great deal of coding and integration is required to retrieve, parse and make the data actionable.

You can natively access these data in a formatted way using Cerberus Testing. You just have to define the two required actions in low-code after each page you navigate. The two specific actions are the following:

  • “waitNetworkTrafficIdle” will start data collection and the right moment
  • “setNetworkTrafficContent” will actually collect the data
Figure 2: You need two specific actions after each page to collect the data.

From that point, your test case will collect the network data at each execution. You can test your setup by running the test case. One point to secure is that your Selenium robot is running with a proxy to actually access the external data. If you use a Cloud plan, this is natively available, else you need the specific robot available on GitHub here.

Figure 3: The data are natively formatted in JSON to ease your testing in Cerberus.

You access the above data in a formatted way after the execution. The data are in JSON to ease your reading and control and are already split with global and per domain metrics. You can concentrate on the verifications without the need to code technical parsing.

You are now ready to add the desired controls in your various test cases.

Add your expectations with filters and controls

You can replicate the shared structure to capture network data in your test cases. Using the filters and JSON verification will ease your journey: you just have to specify the various expectations per provider with an action and a control.

The action remains with the “setNetworkTrafficContent” where you can use a filter or not. In our case, we filter on “google-analytics” to have a simpler control afterward, already filtering the number of calls performed. 

Figure 4: Define the necessary filters and controls per 3rd-party in low-code.

The control on “$.stat.total.requests.nb” access to the value in the formatted JSON prepared by Cerberus Testing. “Stat” stands for “statistics” and “nb” for “number”. You can use the same structure and control keyword to verify any element of the JSON.

Figure 5: Access the results easily in the native test reporting.

You can even add these controls to your library, to be reusable across test cases and replicable within your test. You can also add dynamic parameters per country or from a previous test case using a property.

This is only the start of improving your product quality.

Expand your initiative with continuous improvement

We covered the 3 main steps necessary to add 3rd-party APIs called verifications within your web application. Cerberus Testing enables you to accelerate your test automation journey by natively providing the required features.

We shared the simple case of ensuring a call was made to a 3rd-party. You can go further with the framework and data available by checking the results of the API call, and even verify the response time remains under a particular SLA.

User interfaces are the results of a valuable composition of technologies. As engineers, it is our responsibility to ensure their integration is supporting a successful user experience constantly improving.
Interested in improving your user experience? Get Cerberus Testing for free here.

Leave a comment

Your email address will not be published. Required fields are marked *

Cerberus-Testing Terms Of Service


Website Terms and Conditions of Use

1. Terms

By accessing this Website, accessible from http://vgeouyk.cluster030.hosting.ovh.net, you are agreeing to be bound by these Website Terms and Conditions of Use and agree that you are responsible for the agreement with any applicable local laws. If you disagree with any of these terms, you are prohibited from accessing this site. The materials contained in this Website are protected by copyright and trade mark law. These Terms of Service has been created with the help of the Terms of Service Generator and the Privacy Policy Template.

2. Use License

Permission is granted to temporarily download one copy of the materials on Cerberus Testing's Website for personal, non-commercial transitory viewing only. This is the grant of a license, not a transfer of title, and under this license you may not:

  • modify or copy the materials;
  • use the materials for any commercial purpose or for any public display;
  • attempt to reverse engineer any software contained on Cerberus Testing's Website;
  • remove any copyright or other proprietary notations from the materials; or
  • transferring the materials to another person or "mirror" the materials on any other server.

This will let Cerberus Testing to terminate upon violations of any of these restrictions. Upon termination, your viewing right will also be terminated and you should destroy any downloaded materials in your possession whether it is printed or electronic format.

3. Disclaimer

All the materials on Cerberus Testing’s Website are provided "as is". Cerberus Testing makes no warranties, may it be expressed or implied, therefore negates all other warranties. Furthermore, Cerberus Testing does not make any representations concerning the accuracy or reliability of the use of the materials on its Website or otherwise relating to such materials or any sites linked to this Website.

4. Limitations

Cerberus Testing or its suppliers will not be hold accountable for any damages that will arise with the use or inability to use the materials on Cerberus Testing’s Website, even if Cerberus Testing or an authorize representative of this Website has been notified, orally or written, of the possibility of such damage. Some jurisdiction does not allow limitations on implied warranties or limitations of liability for incidental damages, these limitations may not apply to you.

5. Revisions and Errata

The materials appearing on Cerberus Testing’s Website may include technical, typographical, or photographic errors. Cerberus Testing will not promise that any of the materials in this Website are accurate, complete, or current. Cerberus Testing may change the materials contained on its Website at any time without notice. Cerberus Testing does not make any commitment to update the materials.

6. Links

Cerberus Testing has not reviewed all of the sites linked to its Website and is not responsible for the contents of any such linked site. The presence of any link does not imply endorsement by Cerberus Testing of the site. The use of any linked website is at the user’s own risk.

7. Site Terms of Use Modifications

Cerberus Testing may revise these Terms of Use for its Website at any time without prior notice. By using this Website, you are agreeing to be bound by the current version of these Terms and Conditions of Use.

8. Your Privacy

Please read our Privacy Policy.

9. Governing Law

Any claim related to Cerberus Testing's Website shall be governed by the laws of fr without regards to its conflict of law provisions.

Thank you for your interest in cerberus,

In order to proceed with your SaaS we need some in order to confirm your instances accesses.

Please provide accurate contacts to secure the process.

You can cancel any time the subscription, please read Terms of Use.