You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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;
And in the file JunitReporter.
I changed the method
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
The text was updated successfully, but these errors were encountered:
Note that this won't cause tests to be marked as SKIPPED in Cucumber. They'll be defined as PENDING but when non-strict is enabled but these count as skipped in JUnit terms.
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;
And in the file JunitReporter.
I changed the method
private void handleHook(Result result) { if(result.getStatus().equalsIgnoreCase("skipped")){ executionUnitNotifier.addFailedAssumption((AssumptionViolatedException) result.getError()); ignoredStep = true; }else if (result.getStatus().equals(Result.FAILED) || (strict && isPending(result.getError()))) { executionUnitNotifier.addFailure(result.getError()); } else if (isPending(result.getError())) { ignoredStep = true; } }
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
The text was updated successfully, but these errors were encountered: