• Lets say I have such testcase in my web application:
    1. login
    2. click "add folder" button
    3. Notification about succesfully added folder appears
    4. Click some home button (e.g for performing action after)
    5. Folder appears (is created & displayed)

How would your approach look like speaking of automated testing? I'm between two options:

  • One test case approach
    1. login
    2. click "add folder" button
    3. ASSERT if notification appeared
    4. click some home button
    5. ASSERT if Folder appeared (is created & displayed)


  • Two test cases approach

    • first testcase

      1. login
      2. click "add folder" button
      3. ASSERT if notification appeared
    • second testcase

      1. login
      2. click "add folder" button
      3. click some home button
      4. ASSERT if Folder appeared (is created & displayed)

My question/concern is: Im thinking about two test cases approach because if first assert fails my testcase is still able to catch the second assert. In first case, if notification assert fail, im not able to test if folder was created.

2 Answers 2


I would choose the second approach (of using two tests) because:

  • I like my specs to follow the Given, When, Then format, with the Then being the assert and thus always being at the end even if not using Cucumber or Gherkin .
  • I like to use asserts to reflect the overall reason for the test example, not being used as intermediate 'did I get to step x' code.
  • I like the test to be asserting one thing or one single set of things together (common in UI tests), but without actions between them.
  • I like to always have asserts at the bottom for consistent easy reading.
  • Two assertions mean two tests even if you do jam them into one syntax-wise.
  • Thank you man - I was thinking the same way. Really good reasoning :) Feb 17, 2018 at 9:06
  • +1 for the test to be asserting one thing at the bottom. Feb 17, 2018 at 13:06

Design tests to have only one hard assertion per test at the bottom.

Please read on Soft vs. hard assertions.

Main difference is:

HardAssert - throws errors immediately, test is stopped &marked as failed and test suite continues with next test in the suite. Example: Runtime error on login instead of Home page display.

SoftAssert - collects errors during test but the test continues till the end where all failures are reported in test result . Example : Typo in Page title name.

  • Yep, that's also good point. I was considering this approach as well <thinking_face> Although this make tests more complex. To be honest I prefer more simply tests. What do you think? Feb 18, 2018 at 11:40
  • What are your thoughts on a sad test for a form error page that has to assert that each of 30 fields values were re-displayed correctly with the value originally entered ? Feb 18, 2018 at 12:16
  • I would have one test with 30 soft asserts. Feb 18, 2018 at 12:29
  • Whats your answer @MichaelDurrant? :D Feb 18, 2018 at 20:17
  • Shinigamiyuu,I guess the question was asked to you, what's your answer? Feb 18, 2018 at 20:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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