Your Guide to Data-Driven Testing
Quite simply, data-driven testing is taking a test, parameterizing it and then running that test with varying data. This allows you to run the same test case with many varying inputs, therefore increasing coverage from a single test. In addition to increasing test coverage, data driven testing allows the ability to build both positive and negative test cases into a single test.
Let’s, in fact, say that our boss has given us this spreadsheet full of information with a bunch of different users and products they’re going to buy and amounts of products and all that stuff. All that data needs to be entered into our system. It would be very inconvenient if we had to create a separate test case for each individual line in this spreadsheet. I’d go right out of my mind with boredom and tedium. I’d imagine most of you guys would, too.
But what our data-driven testing capabilities allow us to do is read data in from a spreadsheet-- feed it into our application. And that way, we only create our test case once. And we can add new test cases to our data source, like this Excel file, as needed.
What is Data-Driven Testing?
Data-driven testing (DDT) is data that is external to your functional tests, and is loaded and used to extend your automated test cases. You can take the same test case and run it with as many different inputs as you like, thus getting better coverage from a single test. This could be an Excel document, an XML file, a MySQL database, etc.
The data is what drives the test, henceforth, why it is called data-driven testing. Data-driven testing can save time and money for a development team because you don’t need to test each piece of data manually, but rather with the help of testing software, such as TestComplete, you can automate the testing process. You may also change the parameters of the test case to reuse the test case as many times as you like in other instances.
Using DDT, we can also setup positive and negative test cases into a single test. Positive test cases tests whether the input data within specified boundaries holds true. For instance, a date of 4/12/2013 in the date field will presumably work because it is a date in the correct format. This test would not pass if the test concluded that this is false and gave us an error. Contrary to positive-test cases, negative test cases tests input data that does not fall within the boundaries of that data entry.
For instance, if you entered 40/40/40 into a date field on a spreadsheet, you should receive back an error that this data is invalid for this particular field. If you do not receive an error for invalid data then the negative test fails.
A Visual Example of Positive vs. Negative Testing
What is a framework and how does this help me?
In order to setup a data-driven test case more quickly, we must understand what a framework is and how we can use it to make our lives easier. Simply put, a framework is a library or set of libraries that contain reusable code. In the case of test automation, we refer to this framework
as our test automation framework.
Long ago, in the late 1990’s to be exact, a group of developers sat down to start writing code for their groundbreaking application idea. When they came to consult one another with their code review a few weeks later, they came to the realization that in certain instances they wrote the same code.
For instance, they all wrote code for a radio button. They learned that code is reusable and writing code for a radio button ten times over is not only redundant but a big waste of time and money. This led to the creation of frameworks or libraries of reusable code.
In DDT, the use of frameworks allows us to quickly grab code that has already been written instead of writing it from scratch. Whether it be the ability to pull a script from a framework or the software’s ability to easily find and fix errors within a script, you don’t need to be an able programmer.
To read more about data-driven testing, and how you can simplify the process using TestComplete, download our free eBook, "The Complete Guide to Data-Driven Testing":