AssumptionViolatedException not causing test to be skipped #95

Closed
murphp15 opened this Issue Nov 25, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@murphp15

Summary

We are migrating from an in house BDD framework to cucumber.
In our in house framework tests are skipped if the system is not in a certain state which can only be determined at runtime. We want to be able to support this in cucumber.
For example if test 1 is about to be run it will check that server x and y are active, if not it will skip this test.

Description

I have found a way to mimic this behaviour in cucumber except there seems to be a bug preventing us from doing it.
To mimic it I use tags(annotations) and the before command.
In the before command I check the state of the system, if the system is not how the test wants it then it will throw and org.junit.AssumptionViolatedException. This should cause the step to be skipped.
However we see that this causes the test to fail. We are running our tests in strict mode.

Possible Solution

I have fixed it in a local clone of your repo.
I made the following 2 changes to the file cucumber.runtime.Runtime./
In the runHookIfTagsMatch I added the section
if(isBefore){ status = isPending(t) ? "skipped" : Result.FAILED; }else{ status = isPending(t) ? "pending" : Result.FAILED; }

And in the runStep I changed the line
status = isPending(t) ? "pending" : Result.FAILED;
to
status = isPending(t) ? "skipped" : Result.FAILED;

I my no means see this as a full solution and it is untested on other use cases but I would be happy to work with you guys to implement a full solution for this issue.

Looking forward to hearing from you regards, Paul

@aslakhellesoy

This comment has been minimized.

Show comment Hide comment
@aslakhellesoy

aslakhellesoy Nov 25, 2016

Contributor

Can you please create this issue in the cucumber-jvm project? Thanks!

Contributor

aslakhellesoy commented Nov 25, 2016

Can you please create this issue in the cucumber-jvm project? Thanks!

@murphp15

This comment has been minimized.

Show comment Hide comment
@murphp15

murphp15 Nov 25, 2016

Done. Thanks!

Done. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment