What is data driven framework?

When we talked about different types of frameworks, we talked about data-driven framework. As we all know, data in an application flows across different modules and layers of the application and so we need to think about how to structure our data and pass it to different layers. The layers can be database, api, messaging engines, browser UI and so on. Since we are focused on test data here, we would talk in terms of how to input and output data through an Automation framework and what capabilities do we have to facilitate that movement of data.

Where is it useful?

In financial and heathcare sector, data is an extremely important piece of IT system, in fact data handling is to be done with extreme care. With respect to Automation, we will need to think about how we can set data (with multiple data sets) on the browser UI through selenium. We have already seen enough number of examples in Test Data section in terms of data-driven capabilities.

There might be situations where we might already have data in an existing format and we would want to re-use that to set values during Automation. That means we might have different data formats. Luckily we already covered dealing with test data in multiple formats again in the Test Data Section. With increasing number of layers in an integrated application, depending on data at each layer might become tricky at times, especially if each layer is managed by a different team and each team has different timelines and priorities. In such situations, we have to rely on data virtualization. We will talk about data Virtualization too over time in other posts. For now, as a revision, we already have capabilities to parse data in any of the following formats.

  • Excel
  • XML
  • JSON
  • YML
  • Database

Data Structures:

Some of the below data structures will be helpful while designing a data driven framework. It is not rocket science for sure :)

  1. Hash (key, value pairs)
  2. Arrays
  3. Data Tables

Why do we need these data structures? Because using these we can build a loop and repeat set of actions for different data sets.

Thankfully, cucumber already supports Data Tables using Scenario Outline, so we need not sweat over that. However if we are creating the data from scratch, cucumber data tables are very helpful, but if we already have data in existing files, we could use one of the formats mentioned above and we have covered the parsers for each of the format above in Test Data section.

Shouldn’t data reside in page-object?

Well, it depends ! If you have an application where you have luxury to massage, transform and do all kinds of things, before using it – sure, you can associate the page-data with the page-object. Here we are making an assumption to solve a bigger problem [because page-data definitely will be easier to handle, by probably declaring a method inside page-object and accessing that page’s data] – that is, we have existing data and the data set is for the entire workflow

Implementation?

Continue reading the next posts to start with using excel