OBLYTECH Logo
OBLYTECH Logo

Using AI to Write Data Pipeline Tests: Coverage Limits

An assistant writing data pipeline tests builds them from the code, schema and sample rows it can see. That covers routine checks well. It misses the failures your pipeline has already produced, such as late source files and changed field meanings. Your team has to add those known cases itself.

Why generated tests stop at the cases they can imagine

Generated tests reflect the inputs they were given. Code and schema describe the intended behavior of a transformation: which columns exist, which types they hold, and which fields must be present. A test written from those inputs checks that intended behavior. The result confirms the pipeline does what its code says. It does not confirm the pipeline handles the feeds it actually receives.

The gap is easy to miss because the suite passes. A green run shows that the cases in the suite behaved as expected. It says nothing about inputs the suite does not contain. Teams that read a passing run as proof of coverage usually find the missing cases during an incident.

Sort the coverage gap into four groups

Before adding tests, sort the gap by the kind of failure a pipeline can have. Each group has a different source of truth.

  • Arrival and timing: files or API responses that land late, land twice or arrive out of order relative to the jobs that depend on them.
  • Source drift: a field that keeps its name but changes format, units, code values or meaning in the source system.
  • Historical incidents: inputs that caused a past defect, a failed reconciliation or a manual correction.
  • Rules held by people: exceptions that a sales operations lead or finance contact applies from memory, such as how a region code is treated after a reorganization.

The first two groups can often be described from the pipeline configuration and the change notices that source owners send. The last two usually live in tickets, runbooks and people’s heads, so they need a deliberate collection step before anyone writes a test.

Build the known-failure register before generating tests

A known-failure register is a list of inputs that your pipeline has mishandled or could mishandle, each tied to an expected result. Build it first, then give it to whoever writes the tests, human or assistant. The assistant then generates against concrete cases instead of guessing at them.

  1. Pull each incident, rollback and manual correction from the job history and support tickets for the last year.
  2. For each one, describe the input that caused it in plain terms, with a sample row or file where you can.
  3. Write the result the pipeline should produce, including what it should reject or quarantine.
  4. Name the stage where the check belongs, such as ingestion, transformation or load.
  5. Assign an owner who can confirm the expected result when the rule is unclear.

Teams often skip the first step and start from the schema. That produces a tidy suite that follows the code closely and misses the failures that take the longest to track down. If you already keep a small evaluation set for AI answers, the same method carries over: a fixed set of cases, each with an expected outcome and a stated reason for existing.

For help planning this work, see AI and ML services.

Write the human-authored cases so reviewers can trace them

Human-written cases should be easy to read, run and trace back to their origin. A test named for the behavior it guards is easier to defend than one named for a line number. Keep three things together: the input fixture, the assertion and a short comment naming the register entry.

  • Name each test after the behavior it guards, for example “rejects a partner file received after the cutoff.”
  • Keep the input fixture beside the test rather than in a shared folder that other tests can change.
  • Put the register identifier in the test header so a reviewer can open the original incident.
  • Record the role of the person who confirmed any business-rule expectation.

Mark which tests came from the register and which came from the assistant, using a name prefix or a header tag. When a generated test fails, the reviewer can then tell whether they are looking at a cheap check on a common path or a case that has already cost the team time once.

Place each test at the stage where it can fail

Where a test runs decides what it can catch. Assistant-written suites often collect in one layer by default, usually unit tests, because the transformation code is easiest to call there. Spread the suite across three stages instead.

  • Transformation logic: small tests with fixed inputs, each checking one rule such as a currency conversion or a status mapping. They run quickly and fail with a clear message.
  • Load and integration: a sample batch run through ingestion and load into a test schema, checking row counts, key uniqueness and the handling of rejected records.
  • Production data checks: freshness, control totals against the source system, and range or null checks on loaded tables. These catch arrival and drift failures that unit tests cannot see.

Keep the production checks few and specific. A check that fires on normal runs gets muted, and a muted check protects nothing. Set thresholds from the expected results in the register rather than from a default percentage borrowed from another system.

Check the generated suite for blind spots

Once the register exists, review the generated suite against it. Work through a fixed set of questions so the review stays short.

  1. Does each generated test state its input and the rule it checks, or does it just assert that the job completed?
  2. Does a test compare output with an independent figure, such as a source system count or a control total, instead of the pipeline’s own count?
  3. Are empty input, duplicate keys, a rerun of the same batch and an added source column covered?
  4. Does a deliberately broken rule make at least one test fail? Change one rule on a branch and confirm the suite notices.
  5. Does any test assert current output that may itself be wrong? Snapshot-style tests lock in defects that were present when they were written.

Keep coverage honest after release

Coverage drifts as sources change. A suite that was complete at go-live can miss a new field, a new partner or a shifted load window within months. Treat each production defect as a coverage finding, and record it in the register before the fix is merged. That way the gap stays tracked even when the fix is quick.

Review the register after each source change and each incident. Retire tests that repeat another test’s input and assertion, since duplicate tests slow the run without adding coverage. Keep the assistant’s role narrow in this loop. It can draft a test for an entry someone has written, and a person decides whether the expected result is right.

Test runners, CI tools and scheduling platforms report skipped and errored tests in different ways. Confirm on your own setup that a failing generated test blocks the deploy instead of showing up just in a log.

Once the pipeline runs in production, watch for changes that slip past the suite. Detecting quality drift in production AI features covers the monitoring side. Pipelines that load Salesforce records share many of these rules, so the Salesforce data quality migration guide and the data steward duplicate review routine are worth reading when duplicate keys are in scope.

Questions about coverage for generated pipeline tests

Should generated tests live in the same suite as hand-written ones?

Yes, in the same runner, with a visible marker for origin. Separate folders make it harder for reviewers to spot two tests that guard the same rule, and a single run gives one result for the deploy gate. A name prefix or header tag is enough to show where each expected result came from.

Who should approve a generated test before it blocks a deploy?

The engineer who owns the transformation should confirm that the test exercises the rule its name describes. If the test encodes a business rule, the rule’s owner or a data steward should also confirm the expected result. Hold a test in a review state until both checks are done, so it does not block releases on an unconfirmed expectation.

Does a larger test count mean better coverage?

No. Count says little about what a suite exercises. Fifty tests that feed the same clean sample through the same path check one case fifty ways. Compare the register with the tests instead, and ask which entries have no test that could fail them.

Does the register need a dedicated tool?

No. A versioned file in the pipeline repository works well if each entry has an identifier, a sample input, an expected result, a stage and an owner. Move to a dedicated tool when several teams share the same sources and need to edit entries without merging code.

Can an assistant suggest which register entries are missing?

It can propose candidates from the schema, such as nullable keys, fields that feed more than one output, or joins without a unique match on one side. Treat those as prompts for an owner to check against real history. A suggested case is not evidence that the source sends that input.