Quite simply, data-driven testing is taking a test, parameterizing it andthen running that test with varying data. This allows you to run thesame test case with many varying inputs, therefore increasing coveragefrom a single test. In addition to increasing test coverage, data driventesting allows the ability to build both positive and negative test casesinto a single test.
Let’s, in fact, say that our boss has given us this spreadsheet full of informationwith a bunch of different users and products they’re going tobuy and amounts of products and all that stuff. All that data needs tobe entered into our system. It would be very inconvenient if we had tocreate 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 imaginemost of you guys would, too.
But what our data-driven testing capabilitiesallow us to do is read data in from a spreadsheet-- feed it into ourapplication. And that way, we only create our test case once. And wecan 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 cantake the same test case and run it with as many different inputs as youlike, thus getting better coverage from a single test. This could be anExcel document, an XML file, a MySQL database, etc.
The data is whatdrives the test, henceforth, why it is called data-driven testing. Data-driventesting can save time and money for a development team becauseyou don’t need to test each piece of data manually, but rather with thehelp of testing software, such as TestComplete, you can automate thetesting process. You may also change the parameters of the test case toreuse the test case as many times as you like in other instances.
Using DDT, we can also setup positive and negativetest cases into a single test. Positive test casestests whether the input data within specifiedboundaries holds true. For instance,a date of 4/12/2013 in the date field willpresumably work because it is a date inthe correct format. This test would notpass if the test concluded that this isfalse and gave us an error. Contraryto positive-test cases, negative testcases tests input data that does not fallwithin the boundaries of that data entry.
For instance, if you entered 40/40/40into a date field on a spreadsheet,you should receive back an errorthat this data is invalid for thisparticular field. If you do notreceive an error for invaliddata then the negative testfails.
Stay up to date with the latest API news
Subscribe to our newsletter
Your privacy matters. This information will be used to provide you with best practices gained from our community of 16 million+ software experts, just like you. By submitting this form, you agree to our Terms of Use and Privacy Policy.
Thank you, you're now signed up for SmartBear's API newsletter!
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 understandwhat a framework is and how we can use it to make our liveseasier. Simply put, a framework is a library or set of libraries that containreusable 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 downto start writing code for their groundbreaking application idea. Whenthey came to consult one another with their code review a few weekslater, they came to the realization that in certain instances they wrotethe same code.
For instance, they all wrote code for a radio button.They learned that code is reusable and writing code for a radio buttonten 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 hasalready been written instead of writing it from scratch. Whether it be theability to pull a script from a framework or the software’s ability to easilyfind 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":
See also:
- Automating Gameplay with TestComplete
- The Half-Life of Innovation
- Load Testing 101: Essential Tips for Developers and Testers