Discussion:
[Cucumber] [Cucumber JVM] how to extract feature and scenario name at run time
satish gowda
2015-06-16 04:10:03 UTC
Permalink
I am trying extract the feature and scenario at run time


import gherkin.formatter.model.Scenario;
import cucumber.api.java.Before;

@Before
public void before(Scenario s) {
System.out.println("currently executig scenario " + s.getName());
}

getting error "cucumber.runtime.CucumberException: When a hook declares an
argument it must be of type cucumber.api.Scenario. "
could some one tell how to extract the feature and scenario at run time
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Paolo Ambrosio
2015-06-16 07:44:21 UTC
Permalink
Post by satish gowda
I am trying extract the feature and scenario at run time
import gherkin.formatter.model.Scenario;
import cucumber.api.java.Before;
@Before
public void before(Scenario s) {
System.out.println("currently executig scenario " + s.getName());
}
getting error "cucumber.runtime.CucumberException: When a hook declares an
argument it must be of type cucumber.api.Scenario. "
You are importing gherkin.formatter.model.Scenario and not
cucumber.api.Scenario.
Post by satish gowda
could some one tell how to extract the feature and scenario at run time
Hooks haven't been designed with reporting in mind; for that you
should define your own formatter. From the hook's point of view the
feature is irrelevant.

What are you trying to do in the hook?


Paolo
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
satish gowda
2015-06-17 03:31:43 UTC
Permalink
Post by Paolo Ambrosio
Post by satish gowda
I am trying extract the feature and scenario at run time
import gherkin.formatter.model.Scenario;
import cucumber.api.java.Before;
@Before
public void before(Scenario s) {
System.out.println("currently executig scenario " + s.getName());
}
getting error "cucumber.runtime.CucumberException: When a hook declares
an
Post by satish gowda
argument it must be of type cucumber.api.Scenario. "
You are importing gherkin.formatter.model.Scenario and not
cucumber.api.Scenario.
Post by satish gowda
could some one tell how to extract the feature and scenario at run time
Hooks haven't been designed with reporting in mind; for that you
should define your own formatter. From the hook's point of view the
feature is irrelevant.
What are you trying to do in the hook?
Paolo
even i tried with cucumber.api.Scenario.
but in that i can not find getName() function

is there any way to fetch the Scenario and Feature name??
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Paolo Ambrosio
2015-06-17 05:46:49 UTC
Permalink
Post by satish gowda
Post by Paolo Ambrosio
Post by satish gowda
I am trying extract the feature and scenario at run time
import gherkin.formatter.model.Scenario;
import cucumber.api.java.Before;
@Before
public void before(Scenario s) {
System.out.println("currently executig scenario " + s.getName());
}
getting error "cucumber.runtime.CucumberException: When a hook declares an
argument it must be of type cucumber.api.Scenario. "
You are importing gherkin.formatter.model.Scenario and not
cucumber.api.Scenario.
Post by satish gowda
could some one tell how to extract the feature and scenario at run time
Hooks haven't been designed with reporting in mind; for that you
should define your own formatter. From the hook's point of view the
feature is irrelevant.
What are you trying to do in the hook?
Paolo
even i tried with cucumber.api.Scenario.
but in that i can not find getName() function
You must use cucumber >1.1.6
Post by satish gowda
is there any way to fetch the Scenario
Yes.
Post by satish gowda
and Feature name??
No.


Might give you an alternative approach if you answer the question in
my previous mail.
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Doug Harter
2015-08-28 17:55:35 UTC
Permalink
Paolo,

I'm integrating Applitools Eyes with my Cucumber tests. I would like to
get the Feature name in the Before Hook to set the BatchInfo object in Eyes
object. It would then group all comparisons by Feature.
Im using TestNG and thinking about just explicitly implementing
Post by Paolo Ambrosio
Post by satish gowda
I am trying extract the feature and scenario at run time
import gherkin.formatter.model.Scenario;
import cucumber.api.java.Before;
@Before
public void before(Scenario s) {
System.out.println("currently executig scenario " + s.getName());
}
getting error "cucumber.runtime.CucumberException: When a hook declares
an
Post by satish gowda
argument it must be of type cucumber.api.Scenario. "
You are importing gherkin.formatter.model.Scenario and not
cucumber.api.Scenario.
Post by satish gowda
could some one tell how to extract the feature and scenario at run time
Hooks haven't been designed with reporting in mind; for that you
should define your own formatter. From the hook's point of view the
feature is irrelevant.
What are you trying to do in the hook?
Paolo
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Rafaela Souza
2015-09-30 10:35:22 UTC
Permalink
I am trying to do the same, the Scenario is working for me, but the feature
name it is impossible to get. I couldn't find anything at all.
Post by satish gowda
I am trying extract the feature and scenario at run time
import gherkin.formatter.model.Scenario;
import cucumber.api.java.Before;
@Before
public void before(Scenario s) {
System.out.println("currently executig scenario " + s.getName());
}
getting error "cucumber.runtime.CucumberException: When a hook declares an
argument it must be of type cucumber.api.Scenario. "
could some one tell how to extract the feature and scenario at run time
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Paolo Ambrosio
2015-09-30 18:18:00 UTC
Permalink
Post by Rafaela Souza
I am trying to do the same, the Scenario is working for me, but the
feature name it is impossible to get. I couldn't find anything at all.

You have replied to at least a thread that where it is mentioned that to
get the feature name you need a custom formatter and not a hook.

In hooks that information is not available as it's an antipattern. If you
need it good chances are that you are misusing hooks for something they
were not designed for.

What is your use case?
Post by Rafaela Souza
Post by satish gowda
I am trying extract the feature and scenario at run time
import gherkin.formatter.model.Scenario;
import cucumber.api.java.Before;
@Before
public void before(Scenario s) {
System.out.println("currently executig scenario " + s.getName());
}
getting error "cucumber.runtime.CucumberException: When a hook declares
an argument it must be of type cucumber.api.Scenario. "
Post by Rafaela Souza
Post by satish gowda
could some one tell how to extract the feature and scenario at run time
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...