Is there a way to exit a test case when the first step fails?
I'm creating tests for an API that updates an existing DB2 row. The first step of the test is a DataSource with an SQL query to select a specific row to update. For example, I may want to test what happens when the API updates rows where timeOfDay='1200'. However, there are times when there are no rows on the database that match the criteria, so the DataSource does not find any data to use in the test, the API request fails, and the test case fails. Instead, I want to exit (or pass) the test without recording a failure.
I've tried playing around with the "Fail on Empty" and "Skip Loop on Empty" options, but I haven't been able to get them to do what I need. Is there a way to skip or pass a test case when the first step fails?
Theres lots of ways to do this. The easiest i suggest is adding 2 new test steps at the start of your test case.
First new test step is JDBC step: select count(*) from table; Second new test step would be the Conditional GoTo step which uses XPATH and set this to jump to the final step in test (that could be a placeholder cos the goto step doesnt support jumping to adifferent testcase) IF zero rows were returned in first JDBC step or jump to next test case (skipping all other steps in test)
Add 2 new test steps at the start of your test case.
First new test step is JDBC step: select count(*) from table; Second new test step is Groovy step with conditional goto like "if jdbc response is zero rows, jump to next testcase (skipping all other steps in testcase), else jump to next JDBC step (which was the original first step).
As im sitting here other ways of doing this are popping in my head. Im sure the other forum members will have various other options
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta