Hello,
I have a two different test that overlap. Let me share the given-when-then statements
test_order_placement.py
# GIVEN The user is on Red pepper Pizza
# WHEN The user clicks on the Add to order button below “Opera”
# AND The user clicks on the Add to order button below “Frutti di Mare”
# THEN Opera and Frutti di Mare appears as order items in Your order
test_order_change.py
# GIVEN The user is on Red pepper Pizza
# WHEN The user adds a “Blue and White” pizza to an order
# AND The user clicks the Delete button next to the order item
# THEN the entire order is removed form Your order (both order items and order total )
Look how how test_order_change relies on the when-step to run. The “when” step in test_order_change is pretty much the same as the “then” step of test_order_placement.
Lets 'say that the first test fails because for some reason pizzas can’t be added to an order. Next the yet I replicate the actions from the first test and then expand on the user behavior to delete an order item. If I only test for the absence of an order how will I know the order was present in the first place?
What is a wise way to address this overlap? So far I thought of two options.
- Use pytest -x flag to stop all tests after the first failure.
- Only keep test_order_change and assert both order placement and order deletion in the same test (I am aware this is bad practice)
Happy to hear your thoughts!