Test example 4 – how to set up a shared fixture
Although it isn't explicitly mentioned, we created a fresh fixture for each of the three previous tests as defined as per the GIVEN tags, a lookup-value record, and a customer record. For speed purposes, however, it does make sense to consider whether you need a fresh fixture for each test or a shared fixture for a group of tests. In the case of scenarios #0001
and #0003
, we could perfectly do with the same LookupValueCode
, no need to create a new lookup value record for each of these tests.
Customer wish
Let's use the part of the customer wish that prescribes to have a Lookup Value Code
field on all sales documents to illustrate how a shared fixture can be achieved. This would come down to the following eight scenarios, leaving out the GIVEN-WHEN-THEN part to save space:
[SCENARIO #0004] Assign lookup value to sales header [SCENARIO #0005] Assign non-existing lookup value on sales header [SCENARIO #0006] Assign...