New to scalatest, can I skip a scenario based on result of previous scenario?

23 views
Skip to first unread message

Christine Li

unread,
Mar 13, 2017, 1:53:21 PM3/13/17
to scalatest-users
I am new to scalatest, currently i have a feature with 3 scenarios the logic is like:
1. scenario("create a service")
2. scenario("run some logic with the service")
3. scenario("cleanup: delete the service")

I am just wondering whether there is a way so only run the 3rd scenario if 2nd scenario is successful, otherewise, skilp 3rd scenario. So we'll keep the artifact for investigating errors.

Many thanks,
Christine

Bill Venners

unread,
Mar 13, 2017, 1:54:26 PM3/13/17
to scalate...@googlegroups.com
Hi Christine,

Take a look at CancelAfterFailure:


Bill

--
You received this message because you are subscribed to the Google
Groups "scalatest-users" group.
To post to this group, send email to scalatest-users@googlegroups.com
To unsubscribe from this group, send email to
scalatest-users+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/scalatest-users?hl=en
ScalaTest itself, and documentation, is available here:
http://www.artima.com/scalatest
---
You received this message because you are subscribed to the Google Groups "scalatest-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalatest-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Bill Venners
Artima, Inc.
http://www.artima.com

Christine Li

unread,
Mar 13, 2017, 4:10:16 PM3/13/17
to scalatest-users
Thanks, Bill for your help.

CancelAfterFailure will work for the scenario I described earlier. But think a bit more, actually what I really want to do is to skip cleanup logic. A better description should be:

1. scenario("create service A")
2. scenario("run some logic with service A")
3. scenario("create service B")
4. scenario("run some logic with service B")
5. scenario("cleanup: delete both services")

If something went wrong with service A, scenario 2 will fail, but I do want to execute scenario 3 and 4. Only skip 5. So we can investigate on failure artifacts.

Is there a way to do it?

Many thanks,
Christine
Reply all
Reply to author
Forward
0 new messages