Pytest Tutorial - 5 | The Basics - How to write data-driven tests?
So far we have understood how to write simple tests in pytests . We also saw pytest in action. In this tutorial we will now learn how to write data driven tests. What are data driven Tests? These are those tests, which tests a functionality using various scenarios mocked through a set of test data. In order to achieve this we pass the test data from external data sources such as csv/excel/yaml/json/database/etc. Now why do we need to pass test data from an external data source? Very simple reasons: If the test data is not passed through an external data source, then everytime we add/update/remove test data, we need to update our code. One test case can be tested using multiple combinations of data to test for various conditions of validation Example 1: you can test login using 2 types of test data Valid credentials Invalid credentials Example 2: you can also test password change functionality with 6 types of test data : (Minimum - 1) allowed length of passwo...