Search code examples
testingautomated-testse2e-testingtestcafeweb-testing

Is there a way to abort a test suite in TestCafe if a test in the middle fails?


I have a series of tests that are dependent on a step in the middle (such as creating an account). The API that I'm using for this is a kind of brittle (which is a separate problem), and sometimes fails. I'd like to be able to just quit the tests in the middle there when that fails, instead of wait for TestCafe to fail the initial assertions for the next few tests that follow. Is there a way to get the test controller to stop, or signify to the fixture that the tests should stop? I immediately thought of Spock's @Stepwise annotation, but I can't find anything like that in the TestCafe docs.


Solution

  • The Stop on First Fail option stops the entire run once a failed test occurred. If I understand your scenario correctly, you could add an assertion for a successful account creation and if it fails, exit the entire run with this option.

    CLI Documentation
    API Documentation (under Parameters)