If there are some possible points of failure in your preconditions, is it a bad practice to put in asserts in your Given steps, or if that is unclear, should Given statements ever fail?

  • Could you please edit your question to explain what you mean by "volatility in setting up preconditions"? Do you mean that something in the setup steps fails so you don't get to your test, or that the setup steps can have different outcomes? – Kate Paulk Aug 11 '17 at 11:43
  • "the setup steps can have different outcomes?" <-- exactly. Thank you. You said it much better than me. Cheers! – Adam Deane Aug 15 '17 at 14:06
  • 1
    If the setup steps can have different (valid) outcomes, then they should not be part of your setup steps. They should be part of separate tests. – Kate Paulk Aug 15 '17 at 14:45

Each test case should have a specific objective that is closely dependent on preconditions.

In order to accurately assert that the test has passed i would recommend including the precondition as a assertion. Failure would indicate that the setup failed, not that the functionality failed. Additional if you need to test how the functionality behaves when a precondition is missing, create a separate test.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.