Introduction to Automated Data Driven Testing for REST APIs

One of the biggest concerns in the industry of Software Testing will always be the concern of Investment that the Companies provide for Testing their Software services. Thus, it leaves us with only options to either reduce our UI testing resources or, better, optimize our efforts for performance testing. Well, Data Driven Testing is one such thing, that can not only optimize your Testing efforts but also can give better results with minimal efforts.

Let’s take a deep dive into this subject..

What is Data Driven Testing?

data-driven-testing

We use several methodologies in making our Software Testing processes faster and effective performance testing. Data Driven Testing is one such methodology.

It is an approach to test automation in which the Test Data is stored into an excel sheet (or any other data file), and the automation logic is written separate from the Test Data.

The UI testing Data is eventually attached to the Automation Logic through variables.

What are the benefits of Data Driven Testing?

There are many benefits of using Data Driven Testing, but let me share with you some of the benefits of API monitoring that you get when you are using Data Driven Testing in vREST (keep in mind that these benefits are confined to Data Driven Testing implementation in vREST):

How to do Data Driven Testing in vREST?

Implementing Data Driven Testing in vREST is a piece of cake.

We will be using Contacts Application’s API (this is a CRUD application where you can create, read, update and delete contacts) for demonstration.

To try out Data Driven Testing, just follow these steps:

(Here is the Github Repository, for Data Driven Testing test cases and sample data file)

Step 1: Setup Test Cases & Variables

Step 2: Bind Test Data file with Test Case for Real-Time Editing

Now, that we have set up our test cases, we created a CSV file as the test data document,

Step 3: Write Test Data

Let’s see how you can write the test data in your CSV document when you are working for API performance testing,

Step 4: Run Test Cases & Analyze Results

You can Run All the test cases and then Copy the Actual Response to the Expected Body in your CSV document when working on automated API testing tools. Let’s see how that is done,

Step 5: Add more scenarios

By now, we have seen how you can easily separate test data from automation logic.

Now, let’s see how you can add more test scenarios into the CSV file.

  • Let’s add a scenario but keep the expected body empty
  • more-scenarios
  • Let’s run this test case
  • analyze-tc
  • Copy the Actual Response to the Expected Body (from the failing iteration)
  • expected-body
  • Let’s run again
  • run-test-cases

    So, you can see how beneficial Data Driven Testing can be for your automated API Testing tools and its workflows.