Lesson 2 of 6
Preconditions and data references
7 min
Listen to this lesson
The most common reason an SAP test case fails on its second outing has nothing to do with the system under test. The case pointed at data that no longer exists, or assumed a setup that nobody wrote down. This lesson covers the two parts of a test case that carry it from one cycle to the next: preconditions and test data. A precondition is anything that must already be true before step 1. Write each one as a statement the tester can confirm in a minute, and agree with the test lead that a missing precondition produces a blocked result instead of a misleading fail. That distinction matters at sign-off: a fail says the system is wrong, a block says the test could not be run fairly. For SAP, preconditions usually fall into a handful of groups.
- Is every precondition confirmed true?Yes → run the steps · No → record blocked, not failed, and tell the data owner
- Did each step produce its expected result?Yes → passed · No → continue
- Was the cause the system, not the setup?Yes → failed, log a defect · No → blocked; fix the setup and rerun
| Group | Weak wording | Checkable wording |
|---|---|---|
| System and client | Use the test system | QAS, client 100, with the transport level for cycle SIT-2 imported |
| User and role | Log on as a sales user | Test user holds the business role for sales order processing in sales area 1710 / 10 / 00 |
| Master data | Customer is set up | Customer in data set DS-O2C-01 exists with sales area data for 1710 / 10 / 00 and no credit block |
| Stock and supply | Material is available | Unrestricted stock of at least 50 pieces of the product in plant 1710, storage location 171A |
| Finance settings | Periods are open | Posting period for today is open for company code 1710 |
| Upstream results | Run the pricing test first | TC-MD-004 has passed in this cycle, so the customer price record is in place |
Turning vague preconditions into checkable ones.
Why hard-coded data breaks
A script that says "display sales order 1000457" or "use customer 17100001" works exactly once in exactly one system. SAP test data is fragile in predictable ways:
- Refreshes and copies: when QAS is refreshed from production or rebuilt for a new cycle, documents created during testing are gone and number ranges restart from wherever the source left them.
- Consumption: a sales order that has been fully delivered and billed cannot be delivered again; stock that was issued is no longer there; an invoice that was paid cannot be paid twice.
- Collisions: two testers using the same order or the same stock in parallel change each other's results.
- Landscape differences: the same customer may carry a different number in the training client, the sandbox and QAS.
- Time: price records and contracts have validity dates, posting periods close, and a delivery date that was in the future during cycle 1 is in the past by cycle 3.
| Cause | What breaks | Fix in the test case |
|---|---|---|
| Refresh or copy | Order 1000457 no longer exists in QAS | Create the order in step 1 and pass ORDER_NO forward |
| Consumption | A billed order cannot be delivered again; issued stock is gone | Postcondition note and a replenishment case before each cycle |
| Collisions | Two testers change the same order or stock | Separate data rows per tester in the data set |
| Landscape differences | Customer number differs between clients | Data sheet marked valid for one system, client and cycle |
| Time | Price records expire; posting periods close | Data owner checks validity before marking the sheet ready |
The fix is to separate what the test does from which data it does it with. Steps refer to roles in the data ("the customer in the data set", "the product in the data set"), and a separate data sheet holds the actual values for this cycle and this system. When the system is refreshed, you update one data sheet instead of 200 scripts. The data sheet also becomes a planning tool: before each cycle, the data owner checks every row against the refreshed system, creates what is missing, and marks the sheet ready. Testers who find a sheet not marked ready know to stop before they waste a morning on false failures.
A variant is one row of data for the same steps. Contoso's order-to-cash case runs with variant A (Great Lakes Fleet Services buying 50 alternators CMC-ALT-100 from plant 1710), variant B (a tax-exempt customer) and variant C (a partial delivery of 30 then 20). One set of steps, three outcomes, and three expected-result rows in the data sheet. Give every data set an owner, usually the key user for the process, and a "valid for" line naming the system, client and cycle, so a tester can tell at a glance whether the sheet is current. Documents created during the run are runtime values. Write them as placeholders and tell the tester to record them: "Create the delivery for the order created in step 2 (record as ORDER_NO)". Later steps then say "for ORDER_NO". The execution record holds the real numbers, which also gives a reviewer the evidence trail.
| Variant A | Variant B | Variant C | |
|---|---|---|---|
| Data | Great Lakes Fleet Services, 50 CMC-ALT-100, plant 1710 | Tax-exempt customer | Order delivered as 30 then 20 |
| Steps | Same steps | Same steps | Same steps |
| Expected result row | Full delivery, normal tax | No tax on the invoice | Two deliveries; order completely processed after the second |
| Runtime values | ORDER_NO, DELIVERY_NO, BILLING_NO recorded during the run | Same placeholders | Two delivery numbers recorded |
SAP's own test automation follows the same principle. In eCATT, a test configuration combines a script with variants of data, and SAP's documentation describes referencing a test data container as the preferred method over typing values into the configuration, so values can be changed in one place for every test that uses them. A manual script that already keeps its data in a referenced sheet is far easier to convert later, because the separation of steps and data has been done. If your project uses SAP Cloud ALM, keep the data sheet next to the test case (as an attachment or a linked document, depending on what your tenant supports) so the two travel together.
What would you do?
Two days after QAS is refreshed for the second test cycle, Contoso's testers report that 60 order-to-cash scripts fail at step 1 with "sales order does not exist". Each script starts by displaying a specific order number. Maria, the order-to-cash key user, asks what to do. What is the best response?
- Write preconditions as statements a tester can confirm quickly; an unmet precondition means blocked, not failed.
- Hard-coded document and master data numbers break after refreshes, consumption, collisions and landscape changes.
- Keep steps stable and put values in a referenced data set with variants; capture created documents as runtime values.
- Data that runs use up needs a postcondition note and a refill plan.
Check your understanding · not graded
Lesson check
1. A precondition is not met when the tester starts. What should the result be?
2. Which precondition is written in a checkable way?
3. What is a runtime value in a test script?
4. In eCATT, where does SAP recommend keeping reusable test data?