Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
AssumptionViolatedException when using junit assume #359
I have a cucumber test that starts something like this:
I want to use the @before (which is the cucumber one and not the unit) to stop my test if the assumption fails. However, the scenario fails (the individual steps are ignored). This is very annoying as my build breaks.
How can I use an Assume and make cucumber ignore the scenario (and report no errors)?
org.junit.internal.AssumptionViolatedException: got: , expected: is
From the Assume javadoc (http://junit.sourceforge.net/javadoc/org/junit/Assume.html):
"A set of methods useful for stating assumptions about the conditions in which a test is meaningful. A failed assumption does not mean the code is broken, but that the test provides no useful information. The default JUnit runner treats tests with failing assumptions as ignored. Custom runners may behave differently. "
Specifically on assumeTrue:
I use assume to enable / disable different tests depending on the environment that the run in (and I would prefer not to do this using e.g. tags). The benefit of assume is that the tests which "fails" the assumption will be ignored.
Cucumber-Core (where the exception will be caught and reported) doesn't depend on junit, so this would require a patch that just looks at the exception class name to determine whether or not to allow the step to pass.
I'd happily accept a pull-request for this.