Reputation: 1
I am working with a situation where I have the following scenario/steps to Test
I have the test cases ready but I need a way to skip the Edit and Delete TCs if the Create TC fails. In other words I need to chain them together so the system understands that if Create was not successful then skip the Edit and Delete test cases (Conditional Skipping).
Is it possible with any existing process like hooks/test Context?
Is there any logic I can use to make this happen?
Thanks in Advance.
Expecting something like below
test('Verify Create New Account Functioning Successfully', async (t: TestController) => {
// if this fails, I can set a variable x=fail
});
test('Verify Edit Account Functioning Successfully', async (t: TestController) => {
// Skip this as create test case failed
if(x == fail) {
test.skip(t.this test);
}
});
Upvotes: 0
Views: 28
Reputation: 16067
Don't have any experience with testcafe, but with unit testing in general, it seems to be generally accepted that each test is better to be written completely independent from other tests and so can be run individually or in any order. (See here for more details)
I am assuming that your edit and delete test tests require a record to be created before they can be run. If so, you have two options.
Write one test that does all three options.
Amend your edit and delete tests to create a new record before attempting to edit/ delete it.
The latter will obviously increase the time taken for the tests and the only real benefit is that it makes it obvious which part is failing.
Upvotes: 0