-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AssumptionViolatedException when using junit assume #359
Comments
Please enlighten me about what Assume is supposed to do. I've never used it. |
Hi Aslak. 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. |
Okay, should the exception class name just be hard coded in the core, or how do you propose that we tell core the class name? |
Yes, I suggest we have a |
OK, I'll try to fix it during this week and send you a pull-request. |
My very first contribution: #363 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
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)?
StackTrace:
org.junit.internal.AssumptionViolatedException: got: , expected: is
at org.junit.Assume.assumeThat(Assume.java:70)
at org.junit.Assume.assumeTrue(Assume.java:39)
at Myclass.assume(Myclass.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at cucumber.runtime.Utils$1.call(Utils.java:40)
at cucumber.runtime.Timeout.timeout(Timeout.java:12)
at cucumber.runtime.Utils.invoke(Utils.java:36)
at cucumber.runtime.java.JavaHookDefinition.execute(JavaHookDefinition.java:59)
at cucumber.runtime.Runtime.runHookIfTagsMatch(Runtime.java:182)
at cucumber.runtime.Runtime.runHooks(Runtime.java:174)
at cucumber.runtime.Runtime.runBeforeHooks(Runtime.java:165)
at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:32)
at cucumber.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:76)
at cucumber.junit.FeatureRunner.runChild(FeatureRunner.java:65)
at cucumber.junit.FeatureRunner.runChild(FeatureRunner.java:20)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at cucumber.junit.FeatureRunner.run(FeatureRunner.java:72)
at cucumber.junit.Cucumber.runChild(Cucumber.java:76)
at cucumber.junit.Cucumber.runChild(Cucumber.java:36)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at cucumber.junit.Cucumber.run(Cucumber.java:81)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
The text was updated successfully, but these errors were encountered: