The concept of data driven testing has been around for quite a long time, and I think it's worthwhile to review its application which can be extremely powerful to automated testing. At the same time, it's also beneficial to know that there are certain situations where it can do more harm than good to try to 'force feed' DDT into the tests. The thing that I like about DDT is that the basic concept is so simple, but yet not many testers know when and how to apply it. And when they find success with it, they try to over-use it. This practice eventually lead to inflexible and broken design in their automation.
Let’s go over the main advantages on DDT and when we should use it to improve our automation. Data driven tests provide its biggest bang for the buck when there are numerous tests which are permutations of one another. For example, testing an input to an application or API parameters. Scenario-based tests can also be data-driven, as long as the general execution steps within the scenario remain unchanged. Recently, I happened to come across some legacy automations at our team, and I noticed that roughly 60-70% of the test scripts are simply data. One major pitfall of having test data coupled with the code makes the code fragile. Anytime there’s a change in requirement, test data may need to be added or updated. As a result, the whole script needs to be edited, compiled, and linked (for non-interpreted languages, that is). So why don’t we just save ourselves the trouble and simply abstract those data out from the test code? They have no business being together in the first place.
IMO, the most difficult aspect of DDT is to recognize that the tests can be data-driven from the get-go. Testers can be so absorbed into coding up the automation and creating a bunch of tests in the shortest amount of time. By simply taking a step back and look at the test cases at hand, one can quickly see the pattern of DDT and how to correctly apply it. This white paper by Keith Zambelich (note it's a Word doc) does an excellent job of detailing the different pieces in DDT and how to go about implementing one.
Let’s take a look at some common pitfalls with DDT approach, which I must admit that I had fallen not once but a few times.