intermediate·8 min read·Updated

Test Data Management for Automation: Fill Tests from Data, and Related Data (Part 2)

Fill a project's existing tests from a data set, preview every change and undo it, then let each row of an Orders sheet pick its user from a Users sheet and check the matches before you run.

This is lesson 9.29, part 2, of Shift-Left API in Depth, the product track of the learning center. In part 1, you added a contract check and saved reviewed sample rows as a data set. Now you put data to work. Everything in this lesson is in every edition.

What is test data management for automation?

Test data management for automation is about getting good data into your tests without editing each one by hand. Data-driven testing binds a sheet to one test. This lesson fills many tests at once, and then links one sheet to another.

What does filling tests from a data set do?

A fill sends a data set's values into tests you already have. With Fill values, each test gets one row. It fills only the fields a request already sends and never adds one. It also keeps values a test chose on purpose: if a boundary test sends an age just over the limit, that age is what the test checks, so it stays.

Columns are matched to fields by name:

  • Different spellings, such as USER_ID and userId, match.
  • A dotted column such as address.city fills a nested field.
  • An expected status column decides which rows a test can take, so a passing test only gets rows that should pass.
  • Expected columns set what a row expects back, and invalid-value columns are never written into a test that must pass.
  • Credentials, content types and linked values stay as they are.

How do you preview, fill and undo?

  1. Go to Project Settings, then Data for Running Tests, then Datasets.
  2. Click Fill tests on a data set's row.
  3. Choose Fill values. The other option, Run each passing test once per row, links tests to the data set instead.
  4. Choose a different row for each test, or the same first row for all, and leave Keep values a test chose on purpose ticked.
  5. Click Preview. Nothing is written yet. You see how many tests will change, and for each one the old and new values. You can also see which tests are skipped and why. A test that already runs once per row of a sheet is skipped, for example.
  6. Untick any test you want to leave alone, then click the Fill button.

Tests are written one at a time with a live count. A filled value counts as your own edit, so generating tests again keeps it. Recent fills lists each fill, its data set, how many tests it changed and when. Click Undo to put the filled tests back. A test that someone edited after the fill keeps its new values, and Undo names it. You can also ask the project assistant to fill or undo, and it shows the same preview as an offer.

Real data often sits in two places. An order row holds a user ID, while the user's name is in a Users sheet. In the video, a test called "Place an order" runs once per row of an Orders sheet.

On the test's Data tab, under Related data, click Add related data. Then choose the Users sheet, say which of its columns to match (ID), and which column of this row it equals (USER_ID). You can pick any saved data set, or a saved data source such as a CSV, a database, an API or one sheet of an Excel workbook. You can then use the matched values in a field, for example the user's name in an order note.

Why check the matches before running?

Click Check matches before you run anything. It shows how to use the related values, and it names any row that has no match. In the video, one order has a user ID that is not in the Users sheet. You can fix the sheet, or leave that row out. The video uses Iteration mode to run only the first three rows, then checks again until every selected row has exactly one match. Rows are chosen first and matched afterwards, so a relation never changes which rows are chosen.

After the run, open View Details on a result: the data row shows the user it matched, and a column that looks like a secret is masked. The related data is read in full once per run, so keep it to the rows you need.

Try it yourself

Pick a data set and click Fill tests. Preview, untick what you would rather keep, fill, then click Undo to see it work. Next, add related data from a second sheet to a data-driven test, click Check matches, and run it. This works in the free edition.

Recap

  • A fill changes only fields a test already sends, and keeps values chosen on purpose.
  • Preview first; undo from Recent fills.
  • Column names steer which rows and expected values a test receives.
  • Related data links each row to its match in another sheet.
  • Use Check matches before running, and fix or leave out any row without a match.

Next, learn how to use AI in API testing with the project assistant. For the wider picture, read test data management best practices.

Hands-on lab

Try it: In Datasets, choose Fill tests on a data set, preview the changes, untick any test you would rather keep, fill, and undo once. Then add related data from a second sheet to a data-driven test and click Check matches.

Enter your email to open the lab steps. One unlock opens every lab in the learning center.

No spam. Protected by reCAPTCHA — Google Privacy & Terms.

Frequently asked questions

What is test data management in an automation framework?+

It is how data reaches your tests and stays usable over time. In Shift-Left API, you can send a data set's values into tests you already have, with a preview first and an undo afterwards, instead of editing tests one by one.

Will filling tests overwrite my negative tests?+

Keep values a test chose on purpose is ticked by default. A value that a boundary or bad-value test sends on purpose is kept, and the preview says why. You can also untick any test before you fill.

How does data driven testing work with two related sheets?+

Related data finds the row in another sheet or data set that belongs to each row, by matching one column to another. Check matches shows any row without exactly one match before you run, so you can fix the sheet or leave the row out.

Read more on the blog