1 Aug 2012 07:07
Re: [Cucumber] [JVM] Not able to figure out the error with before hook
On 7/31/2012 9:59 PM, Bill Ross wrote:
> cucumber.runtime.CucumberException: When a hook declares an argument
> it must be of type cucumber.runtime.ScenarioResult. << "Result"
Who's on First?
Anyway, if an after-style exception is being thrown by a Before, then there's a cuke bug, but also the stack trace looks garbled at the top.
--
-- Rules --
1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
3) If you have a question, don't reply to an existing message. Start a new topic instead.
You received this message because you are subscribed to the Google Groups Cukes group. To post to this group, send email to cukes-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to cukes+unsubscribe <at> googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
On 7/31/2012 9:57 PM, Yogesh Aggarwal wrote:Nor that I see, since the After is fine and it's the Before, which is throwing an exception that seems to indicate an After:
On Wednesday, August 1, 2012 10:18:45 AM UTC+5:30, BillR wrote:
On 7/31/2012 9:38 PM, Yogesh Aggarwal wrote:
> Hi Aslak,
>
> I have the following before and after hooks in one of the classes:
>
> String CurrentMarket;
> <at> Before
> public void executehook(Scenario sc){
How is cucumber to know what to pass to these hooks? (Same with After.)
I think the error is saying you can't have arguments to methods with
these annotations.
Bill
Hi Bill,
This is a cucumber predefined that Before hook method must accept an object of Scenario class and After hook an object of ScenarioResult class.
Thanks!
Hi Yogesh,
Maybe it is a misdirected error and the real problem is that your After throws an idiosyncratic exception?
Bill
> cucumber.runtime.CucumberException: When a hook declares an argument
> it must be of type cucumber.runtime.ScenarioResult. << "Result"
Who's on First?
Anyway, if an after-style exception is being thrown by a Before, then there's a cuke bug, but also the stack trace looks garbled at the top.
--
>
> System.out.print("Inside Before Hook");
>
> List<Tag> tags = sc.getTags();
> if(tags!=null){
>
> CurrentMarket = tags.get(0).toString();
> }
>
> }
>
>
> <at> After
> public void close(ScenarioResult result) throws FileNotFoundException{
> try {
> File sc = this.getScreenshotAs(OutputType.FILE);
> result.embed(new FileInputStream(sc), "image/png");
> } catch(WebDriverException e) {
> System.err.println(e.getMessage());
> } finally {
> super.close();
> }
> }
>
> After hook works fine.
>
> But code always gives error while working with Before hook and due to
> which test fails. What is the wrong in the above code? cucumber
> version used is 1.0.8
>
> cucumber.runtime.CucumberException: When a hook declares an argument
> it must be of type cucumber.runtime.ScenarioResult. public void
> com.nextag.cucumber.search.INTL.ProductSortingOptionsStepDefs.executehook(gherkin.formatter.model.Scenario)
> at
> cucumber.runtime.java.JavaHookDefinition.execute(JavaHookDefinition.java:51)
> 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:193)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
> at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
> 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:193)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
> at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
> at cucumber.junit.Cucumber.run(Cucumber.java:81)
> at org.junit.runners.Suite.runChild(Suite.java:128)
> at org.junit.runners.Suite.runChild(Suite.java:24)
> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
> at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
> at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
> at org.junit.runner.JUnitCore.run(JUnitCore.java:136)
> at
> org.apache.maven.surefire.junitcore.JUnitCoreWrapper.execute(JUnitCoreWrapper.java:62)
> at
> org.apache.maven.surefire.junitcore.JUnitCoreProvider.invoke(JUnitCoreProvider.java:139)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
> at
> org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
> at
> org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
> at
> org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103)
> at
> org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)
>
> cucumber.runtime.CucumberException: When a hook declares an argument
> it must be of type cucumber.runtime.ScenarioResult. public void
> com.nextag.cucumber.search.INTL.ProductSortingOptionsStepDefs.executehook(gherkin.formatter.model.Scenario)
> at
> cucumber.runtime.java.JavaHookDefinition.execute(JavaHookDefinition.java:51)
> 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:193)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
> --
> -- Rules --
>
> 1) Please prefix the subject with [Ruby], [JVM] or [JS].
> 2) Please use interleaved answers
> http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
> 3) If you have a question, don't reply to an existing message. Start a
> new topic instead.
>
> You received this message because you are subscribed to the Google
> Groups Cukes group. To post to this group, send email to
> cukes <at> googlegroups.com. To unsubscribe from this group, send email to
> cukes+unsubscribe <at> googlegroups.com. For more options, visit this group
> at https://groups.google.com/d/forum/cukes?hl=en
>
>
-- Rules --
1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
3) If you have a question, don't reply to an existing message. Start a new topic instead.
You received this message because you are subscribed to the Google Groups Cukes group. To post to this group, send email to cukes-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org. To unsubscribe from this group, send email to cukes+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
--
-- Rules --
1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
3) If you have a question, don't reply to an existing message. Start a new topic instead.
You received this message because you are subscribed to the Google Groups Cukes group. To post to this group, send email to cukes-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org. To unsubscribe from this group, send email to cukes+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
--
-- Rules --
1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
3) If you have a question, don't reply to an existing message. Start a new topic instead.
You received this message because you are subscribed to the Google Groups Cukes group. To post to this group, send email to cukes-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to cukes+unsubscribe <at> googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
RSS Feed