Chapter 11Lesson 03180–250 min

Data-Driven Testing, Templates, Embedded Arguments, and Variants: Configuration, Design Patterns, and Trade-Offs

Choose between explicit tests, templates, loops, embedded arguments, typed rows, and external data by balancing report identity, maintainability, risk coverage, privacy, portability, and CI cost.

Design choicesRisk-based matrixTyped dataExternal dataTrade-offs

Learning objectives

  • Choose templates only when rows share one assertion/workflow contract.
  • Use typed user-keyword arguments deliberately and recognize conversion failures as input-contract failures.
  • Reduce combinatorial matrices using causal/risk reasoning rather than arbitrary sampling.
  • Decide when inline data should move to a versioned external source without making it non-reproducible.
  • Connect test identity and matrix design to parallelism, privacy, runtime cost, and CI reliability.

Current compatibility baseline. Verified 2026-08-31: Robot Framework 7.4.2 is the current stable release and requires Python 3.8+; 7.5b1 is a pre-release and is not required in this chapter. In 7.4.2, templates can use normal, named, and embedded arguments. A templated test containing multiple data rows executes all rows even when one fails or is skipped, then aggregates the test status. User-keyword argument type conversion is stable from Robot Framework 7.3.

1. Start with the contract, not the feature

The decision is not “Can Robot Framework template this?” Most tables can be forced into a template. The useful question is “Do these rows mean the same thing?” If one row requires a browser login, another edits a database, and a third validates a file, one template creates a false abstraction even if the columns can be made to fit.

2. Decision matrix

Choice Strength Cost / risk Default guidance
Explicit named tests Maximum identity and workflow freedom More source repetition Use when behavior differs materially
Suite-level template High density + separate test identity All tests share one template contract Best general data-driven default
Multi-row test template Very compact matrix; all rows attempted One lifecycle and aggregate test status Use for tightly coupled diagnostic matrices
FOR loop Natural procedural iteration Weak variant identity; normal fail-stop semantics Use when loop is part of one scenario
Embedded arguments Readable call name Matching ambiguity if boundaries are vague Use sparingly with clear delimiters
External data source Large data separated from suite Extra provenance/dependency/reproducibility burden Use only when data scale/ownership justifies it

3. Typed template arguments make contracts explicit

Robot Framework 7.4.2 supports user-keyword argument type conversion (introduced in 7.3). That lets a template keyword reject invalid data before business logic runs:

*** Settings ***
Test Template    Value Should Be In Range

*** Test Cases ***             VALUE    MIN    MAX    EXPECTED
Lower boundary                  0        0      10     ACCEPT
Upper boundary                  10       0      10     ACCEPT
Below boundary                  -1       0      10     REJECT

*** Keywords ***
Value Should Be In Range
    [Arguments]    ${value: int}    ${minimum: int}    ${maximum: int}    ${expected}
    IF    $minimum <= $value <= $maximum
        VAR    ${actual}    ACCEPT
    ELSE
        VAR    ${actual}    REJECT
    END
    Should Be Equal    ${actual}    ${expected}

If a row contains abc in the integer column, the keyword call fails during argument conversion. That is different from a business classification of REJECT. The failure evidence should say the input contract itself is invalid.

4. Embedded arguments versus normal named columns

Embedded wording can be excellent for a short sentence such as Identifier "abc" should be ACCEPT. Normal arguments are usually better for long payloads, optional/default arguments, varargs, or values with complex delimiters. Embedded arguments do not support default values or variable-length arguments the way normal arguments do.

Data shape Prefer Reason
Two short human-readable values Embedded arguments Call communicates the case clearly
Long JSON/XML/string payload Normal argument column Avoid matching/delimiter ambiguity
Optional/default configuration Normal arguments Embedded arguments lack default/vararg semantics
Several columns already named in the test header Normal arguments Column names already provide readability

5. Matrix explosion is a modeling problem

Suppose a validation rule appears to vary by 5 identifier lengths × 4 character classes × 3 deployment environments. A naïve Cartesian matrix creates 60 cases. If the validation code does not read the deployment environment, multiplying every input by environment adds runtime without new behavioral coverage.

Dimension Values Causal to rule? Risk-based selection
Length too short, min, nominal, max, too long Yes Keep all five boundaries/equivalence classes
Character class alnum, dash, space, Unicode Yes Keep representative accepted/rejected classes
Environment dev, stage, prod No for local classifier Use one synthetic environment; test environment wiring elsewhere

Risk-based reduction is not random deletion. Document which dimension is non-causal, what evidence supports that claim, and where environment-specific behavior is tested if it exists.

6. Inline data versus external data

Small business matrices are often clearest beside the template. External data becomes reasonable when another team owns the dataset, rows are numerous, or data is generated from a governed fixture. The external source must still be versioned or checksummed, available locally/CI, non-secret, and tied to the exact execution evidence.

Chapter boundary. Chapter 12 covers resource/variable files and project layout. External plugins such as spreadsheet-driven data tools are not required here. The mandatory Chapter 11 path remains Robot Framework core only.

7. One template should have one failure contract

A template named Validate deployment variant that sometimes checks syntax, sometimes checks authorization, and sometimes starts a process forces heterogeneous rows into one result shape. Split contracts when the reason for failure, external state touched, cleanup responsibility, or owning team changes. A compact table is not a benefit if its row semantics are incomparable.

8. CI and parallelism implications

Templates do not create isolation. Separate named tests can later be scheduled independently by a parallel executor; multiple rows inside one templated test stay together as one test lifecycle. Large data tables also inflate logs/output and can repeat expensive setup. Measure row count, setup cost, external-system rate limits, and artifact size before multiplying variants.

9. Privacy and data governance

Do not turn production exports into test matrices just because a template accepts rows. Use synthetic or appropriately de-identified fixtures, keep secrets out of source, and make retention of output.xml/log.html explicit. A failing row often repeats its arguments in diagnostic output.

10. Worked decision

A release-label validator has 8 risk-significant boundary/character cases and 2 hundred historical labels. The production rule is deterministic and pure. Choose the 8 risk-significant cases as named templated tests for every commit. Store the larger historical corpus as a separately versioned regression fixture and run it in a lower-frequency job only if it has demonstrated defect-finding value. Do not mix the two purposes into one 208-row smoke matrix.

11. Knowledge check

What does a type-conversion failure in a typed template keyword mean?

When is a multi-row single templated test preferable to separate named templated tests?

Why is multiplying every case by dev/stage/prod often wasteful for a pure local validation rule?

What must accompany external test data to keep CI reproducible?

12. Summary and next step

Good data-driven design maximizes meaningful variant identity, not row count. Use typed contracts where useful, embedded arguments only when they improve readability, and risk-based matrices that preserve causal coverage. Lesson 4 diagnoses the failure modes that appear when these choices go wrong.

Next lesson

Data-Driven Testing, Templates, Embedded Arguments, and Variants: Diagnostics, Failure Modes, and Production Practices

Continue with Data-Driven Testing, Templates, Embedded Arguments, and Variants: Diagnostics, Failure Modes, and Production Practices. It builds directly on the state, evidence, and operating assumptions established here, so carry those constraints forward rather than treating the next page as an isolated topic.

Further reading

Keep the academy open

Support free, practical DevOps education.

Every lesson is designed to remain readable in a browser, downloadable from GitHub, and usable without a paid learning platform. Contributions help expand and maintain the curriculum.

Ethereum / ERC-20
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0 Send only Ethereum/ERC-20 compatible assets to this address.