The earlier articles used coupon checkout to explore test design. The same questions matter downstream, after a payment becomes a record and that record becomes a report.

What proves the result is correct? What happens when input is repeated? Which failures must not change the published output?

BDD does not require a screen or a button. It brings business and technical people together around concrete examples of expected behavior. A finance analyst reviewing a payment report belongs in that conversation just as a product owner reviewing checkout does. (BDD practices)

The decomposition method from Article 1 still applies. The inputs and outcomes change. The need for agreement does not.

A Plausible Number Can Be Wrong

Stripe represents payment amounts in the currency’s minor unit. For example, 1000 means USD 10.00, while 500 means JPY 500. (Stripe currency documentation)

Consider a reporting transformation that divides every source amount by 100. It produces the correct USD value and the wrong JPY value. Both results remain numeric, non-null, and positive.

Those checks are useful. They just do not prove that the number means what the report claims it means.

The source currency rules are documented; the reporting policies below are illustrative agreements, not Stripe requirements.

Agree Before Generating Tests

Consider this reporting story:

As a finance analyst,
I want daily captured-payment totals by currency,
so that I can reconcile payment activity.

What does “daily” mean? Does the report count notifications or captured payments? Do refunds reduce the total? What happens when yesterday’s payment arrives today?

These are the requirement gaps from Article 6 in a different setting. A generator cannot settle them on the team’s behalf.

For this example, finance, QA, and engineering agree on the following rules:

Decision Agreement for this example
Measure Report gross captured-payment amounts and counts; exclude uncaptured payments and report refunds separately
Currency and units Keep currencies separate; display amounts in major units using the provider’s documented rules, without foreign-exchange conversion
Identity Count each captured payment once within its provider account
Reporting date Use the capture date in UTC, not the arrival date
Late data Revise the affected day’s report when a late capture is processed
Retry The same input snapshot and reporting rules produce the same counts and totals
Invalid input A missing currency blocks the replacement report for that account and date; retain the previous version and set the update status to “Blocked”
Publication Publish a replacement only after processing and required validation succeed

The example covers one full capture per payment. Partial captures, refunds, and settlement reconciliation need separate examples. A reporting day runs from midnight UTC through, but not including, the next midnight.

The scenarios use normalized reporting records, not exact Stripe webhook payloads. A missing currency represents malformed input at the reporting boundary, not a claim that Stripe normally omits the field. Each scenario is independent: existing totals summarize prior payments, and only the new inputs stated in the scenario change.

The table records decisions. The conversation establishes them. BDD connects that discovery work to documented examples and automation. (BDD practices)

Five Behaviors Worth Specifying

Preserve the Payment’s Value

The USD and JPY examples expose a concrete mistake: assuming every currency has two decimal places. (Documented amount representations)

Scenario Outline: Preserve value when preparing a payment for reporting
  Given a captured payment has currency "<currency>"
  And its source amount is <source_amount> minor units
  When the payment is prepared for reporting
  Then its reported amount should be <reported_amount> major units
  And its reported currency should remain "<currency>"

  Examples:
    | currency | source_amount | reported_amount |
    | USD      | 1000          | 10.00           |
    | JPY      | 500           | 500             |

This changes the units within a currency. It does not exchange one currency for another or prescribe how the database must store money.

The examples are deliberately small, following the readable-Gherkin principles from Article 4. They are not a complete currency suite. Implementation tests should also cover the supported currencies’ special rules. (Currency exceptions)

Count Payments, Not Deliveries

Stripe documents repeated webhook deliveries and does not guarantee delivery order. Receiving a notification twice does not necessarily mean receiving two payments. (Duplicate deliveries, event ordering)

Scenario: Repeated delivery does not increase the daily total
  Given account "A" has one captured payment "P1" for USD 10.00 on 2026-10-21
  And its published report for that date includes "P1" once
  When the same notification for "P1" is processed again
  Then the published USD total for that account and date should remain USD 10.00
  And its published USD payment count should remain 1

Also test the positive control: send a distinct USD 10.00 payment “P2” through the same path, and require the total to become USD 20.00 with a count of two. This catches deduplication by amount, which would silently remove a legitimate payment. An unchanged total after repeated delivery can also pass when the handler ignores all input; the companion case helps detect an implementation that ignores all input.

Delivery identity and payment identity answer different questions. Stripe recommends event IDs for repeated delivery of one event, and object ID together with event type for duplicates involving separate Event objects. The integration tests should exercise the identifiers appropriate to the actual event types. (Duplicate-event guidance)

The shared example states the business effect: one captured payment contributes once.

Assign Late Data Correctly

Event time describes when something happened. Processing time describes when a pipeline processes it. Apache Beam distinguishes the two and notes that processing need not follow event-time order. (Beam glossary)

Arrival time can differ from both. This report uses capture time to choose the reporting date.

Scenario: A late capture revises its original reporting date
  Given account "A" has these published USD totals:
    | reporting_date | total  |
    | 2026-10-21     | 100.00 |
    | 2026-10-22     | 0.00   |
  And payment "P2" for USD 10.00 was captured on 2026-10-21 at 23:58 UTC
  And "P2" is absent from both reports
  And its record arrives on 2026-10-22
  When the scheduled reporting run starts
  Then the published USD totals for account "A" should be:
    | reporting_date | total  |
    | 2026-10-21     | 110.00 |
    | 2026-10-22     | 0.00   |

Revising the original date is this example’s policy. A team that locks closed periods needs an example of its adjustment process instead.

Test record selection as well as date assignment. A timestamp cutoff can miss late rows, and a lookback window still misses records arriving beyond it. A correct calculation cannot help a record the pipeline never selects. (dbt late-arriving facts, lookback limits)

Recover Without Counting Twice

Airflow recommends repeatable task outcomes, warns that repeated inserts can duplicate rows, and advises reading a fixed input partition instead of changing “latest” data during a retry. (Airflow best practices)

Test failure after progress has been saved, not only before work starts.

Scenario: Retry preserves totals after interrupted processing
  Given account "A" has no published report for 2026-10-21
  And its input snapshot contains exactly these captured payments:
    | payment | currency | amount | capture_date |
    | P1      | USD      | 10.00  | 2026-10-21   |
    | P2      | USD      | 20.00  | 2026-10-21   |
  And an interrupted attempt saved "P1" but published no report
  When the reporting run is restarted with the same snapshot and reporting rules
  Then a report for that account and date should be published
  And its USD total should be USD 30.00
  And its USD payment count should be 2

The saved progress defines the failure context without prescribing a database table, SQL statement, or checkpoint design. The expected counts and totals are useful consumer-visible checks; they do not alone prove the identity of every contribution or that unfinished output was never exposed during the failed attempt.

The automation must exercise the actual recovery boundary and verify keyed state. dbt’s incremental unit tests check the rows to be inserted or merged, not the final table after that write. A passing selection test is not evidence that the database write is correct. (Incremental unit-test scope)

Refuse an Invalid Publication

“Handle invalid data” leaves the important decision unanswered: what can the consumer still trust?

Under the agreed policy, a missing currency blocks the whole account-day replacement. The record cannot be assigned to a currency total, so publishing the other records alone would silently omit it.

Scenario: Missing currency blocks a replacement report
  Given account "A" has a published USD total of USD 100.00 for 2026-10-21
  And the replacement input includes a new captured payment for that account and date
  And all required data is valid except that payment's missing currency
  When the reporting run attempts to publish the replacement
  Then the update status for that account and date should be "Blocked"
  And no replacement report should be published
  And the previously published report should remain unchanged

The blocked status is part of this example’s agreed consumer contract, not a feature prescribed by Stripe. It makes the rejected update observable instead of presenting the old version as if the refresh succeeded.

The retained version is still old. Separate examples should cover its displayed freshness, operator notification, correction, and replay. This article’s five behaviors are a starting set, not complete pipeline coverage.

Choose the Execution Layer

The principle from What Test Goes Where? still applies: use the least costly layer that can answer the question with confidence.

BDD specifies agreed behavior. Unit, integration, and end-to-end tests describe where the checks execute. A business-readable example need not become a slow dashboard test. (BDD and execution layers)

Risk Suggested execution approach Evidence to inspect
Wrong currency units Transformation unit test Exact values for controlled inputs
Missing currency Data assertion plus publication integration test Invalid record detected; replacement blocked
Repeated delivery Ingestion integration test One business contribution after repeated delivery
Missed late record Incremental-selection and report-update tests Record selected and assigned to its capture date
Incorrect retry or merge Database integration test with interruption Correct stored counts and totals after recovery
Partial report becomes visible Publication integration or small end-to-end test Readers cannot access an unfinished replacement

These are placement recommendations, not exclusive categories. Keep exhaustive parsing cases and technical permutations in focused tests. As When to Skip BDD explains, skipping Gherkin is not skipping testing.

Give AI the Agreed Rules

Provide the decision table, relevant source documentation, and approved examples before asking AI for additional scenarios. Apply Article 5’s reference-example approach to terminology and structure, not as authority for reporting policy.

Generate scenarios from the agreed rules and source contract.
Identify the rule behind each expected result.
Use small fixtures with explicit starting state and new inputs.
Keep technical execution suggestions separate from Gherkin.
List unresolved decisions as questions, not assumptions.

Then apply Article 7’s output critique. Check the expected totals against the inputs. Check what remains unchanged. Check that a scenario does not assume the very success it should verify.

A scenario can be readable, executable, and wrong. A passing result supports only the behavior actually checked, assuming the test itself is sound.

What To Do Monday

1. Choose one consequential output. Pick a report, billing export, or inventory balance. Identify its consumers and what each row and total mean.

2. Agree on a small decision table. Bring the domain owner, engineer, and tester together. Resolve identity, units, dates, corrections, and publication for the chosen change.

3. Challenge one failure path. Repeat input, introduce a late record, or interrupt processing. Calculate the expected result before running the test.

4. Resolve one open question. Record the decision and its owner, then update one scenario’s expected result before automating it.

Where Tooling Fits

KRINO Dokim generates Gherkin from stories and acceptance criteria. In single-story mode, Specification Linting flags weaknesses in your acceptance criteria before generation. Output Critique then reviews the generated scenarios for gaps, redundancy, and missing negative paths. Those features assist review. They do not approve reporting policy or run the pipeline checks. (Product documentation)

Use it to prepare reviewable examples, then implement the checks in the data stack’s testing tools.

The series closes in a different setting with the same discipline: agree on behavior, make it concrete, and test it where the evidence is strongest.

A green run says processing completed. Reviewed examples say what the result should mean.