Data-Driven Testing | Bondar Academy
Course: Playwright API Testing with TypeScript
Module: Test Management
Instructor: Artem Bondar
Lesson Summary
In this lesson, we explore the concept of data-driven testing , which involves executing the same test multiple times with different data sets. This approach is particularly useful in API testing to validate various error messages returned by the API when invalid data is submitted. Key Concepts Data-Driven Testing: Running the same test with different inputs to verify various outcomes. API Validation: Ensuring that the API returns appropriate error messages for invalid requests. Demonstration Using Conduit Application The instructor demonstrates data-driven testing using the Conduit application, focusing on the signup process: Invalid inputs trigger specific error messages, such as Email invalid or Username is too short . Using tools like Postman , different scenarios are tested by sending various request bodies to the API. Testing Framework Setup The lesson covers setting up a testing framework to automate the validation of error messages: Create a new spec file for negative tests. Define test cases for different username lengths (e.g., less than 3, exactly 3, 20, and more than 20 characters). Use an array to store test data and iterate through it using forEach . Assertions and Validations Assertions are added to check if the appropriate error messages are returned or if no error messages are displayed for valid inputs: Use conditional statements to validate the presence or absence of error messages based on input length. Run the tests to ensure all scenarios pass successfully. In conclusion, data-driven testing is a powerful method to efficiently validate API responses without duplicating test cases. This approach enhances testing coverage and maintains code clarity.