Discussion:
[Cucumber] [Cucumber-JVM] Getting annotation on feature level instead of scenario level
(too old to reply)
Gergely Brautigam
2013-04-15 11:22:50 UTC
Permalink
Hi guys.

I want to find out if it possible to get the annotations on a Feature
instead of a Scenario.

I know I can access some part with an @After and the Scenario. Which
contains the Annotation on a Scenario which I found after some digging.

However I can't seem to be able to find the name of the feature and
annotations on it.

For example:

@After
public static runAfterFeatures(Scenario sc) {
logger.log("These are the annotations on a feature: " +
sc.annotationsOnAFeature);
}

Where as a feature looks like this:

@Oneannotation @web @storynumber @quick
Feature: Do something interesting

And I would like to be able to get these annotations from it.

Do I have to implement my own filter for that? If so...where do I register
the implementor with cucumber?

thanks very much!

Greg
--
-- 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/***@public.gmane.org To unsubscribe from this group, send email to cukes+***@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
---
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
aslak hellesoy
2013-04-15 12:11:41 UTC
Permalink
Post by Gergely Brautigam
Hi guys.
I want to find out if it possible to get the annotations on a Feature
instead of a Scenario.
We call them tags, not annotations (just want to avoid confusion)
Post by Gergely Brautigam
contains the Annotation on a Scenario which I found after some digging.
However I can't seem to be able to find the name of the feature and
annotations on it.
@After
public static runAfterFeatures(Scenario sc) {
logger.log("These are the annotations on a feature: " +
sc.annotationsOnAFeature);
}
@Oneannotation @web @storynumber @quick
Feature: Do something interesting
And I would like to be able to get these annotations from it.
Why? What do you need it for?
Post by Gergely Brautigam
Do I have to implement my own filter for that?
What do you mean by filter? What API do you have in mind?

Aslak
Post by Gergely Brautigam
If so...where do I register the implementor with cucumber?
thanks very much!
Greg
--
-- 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
To unsubscribe from this group, send email to
https://groups.google.com/d/forum/cukes?hl=en
---
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/groups/opt_out.
--
-- 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/***@public.gmane.org To unsubscribe from this group, send email to cukes+***@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
---
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Gergely Brautigam
2013-04-15 12:27:50 UTC
Permalink
Hi Aslak.

Because based on the Tag I'd like to perform a certain action for example
put it into a custom report.

I'd like to generate a report based on tags corresponding to JIRA issues /
stories to have a view of how many tests there are for a ticket.

Sorry I might have tried to say Listener not filter. Like a listener for
jUnit test execution for example.

G.
Post by aslak hellesoy
Post by Gergely Brautigam
Hi guys.
I want to find out if it possible to get the annotations on a Feature
instead of a Scenario.
We call them tags, not annotations (just want to avoid confusion)
Post by Gergely Brautigam
contains the Annotation on a Scenario which I found after some digging.
However I can't seem to be able to find the name of the feature and
annotations on it.
@After
public static runAfterFeatures(Scenario sc) {
logger.log("These are the annotations on a feature: " +
sc.annotationsOnAFeature);
}
@Oneannotation @web @storynumber @quick
Feature: Do something interesting
And I would like to be able to get these annotations from it.
Why? What do you need it for?
Post by Gergely Brautigam
Do I have to implement my own filter for that?
What do you mean by filter? What API do you have in mind?
Aslak
Post by Gergely Brautigam
If so...where do I register the implementor with cucumber?
thanks very much!
Greg
--
-- 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
To unsubscribe from this group, send email to
group at https://groups.google.com/d/forum/cukes?hl=en
---
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/groups/opt_out.
--
-- 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/***@public.gmane.org To unsubscribe from this group, send email to cukes+***@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
---
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Gergely Brautigam
2013-04-15 12:54:25 UTC
Permalink
And before you might think that we can use @After("Tagname") that's not an
option unfortunately because Tagname is unknown and differs from story to
story obviously.

It's the title of the ticket. :)

G.
Post by Gergely Brautigam
Hi Aslak.
Because based on the Tag I'd like to perform a certain action for example
put it into a custom report.
I'd like to generate a report based on tags corresponding to JIRA issues /
stories to have a view of how many tests there are for a ticket.
Sorry I might have tried to say Listener not filter. Like a listener for
jUnit test execution for example.
G.
Post by aslak hellesoy
Post by Gergely Brautigam
Hi guys.
I want to find out if it possible to get the annotations on a Feature
instead of a Scenario.
We call them tags, not annotations (just want to avoid confusion)
Post by Gergely Brautigam
contains the Annotation on a Scenario which I found after some digging.
However I can't seem to be able to find the name of the feature and
annotations on it.
@After
public static runAfterFeatures(Scenario sc) {
logger.log("These are the annotations on a feature: " +
sc.annotationsOnAFeature);
}
@Oneannotation @web @storynumber @quick
Feature: Do something interesting
And I would like to be able to get these annotations from it.
Why? What do you need it for?
Post by Gergely Brautigam
Do I have to implement my own filter for that?
What do you mean by filter? What API do you have in mind?
Aslak
Post by Gergely Brautigam
If so...where do I register the implementor with cucumber?
thanks very much!
Greg
--
-- 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
https://groups.google.com/d/forum/cukes?hl=en
---
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
For more options, visit https://groups.google.com/groups/opt_out.
--
-- 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/***@public.gmane.org To unsubscribe from this group, send email to cukes+***@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
---
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Gergely Brautigam
2013-04-15 19:19:06 UTC
Permalink
Well if there is no other way... hacking it shall be...

There you go, how is that for a solution?

Field f = scenario.getClass().getDeclaredField("reporter");
f.setAccessible(true);
JUnitReporter reporter = (JUnitReporter) f.get(scenario);

Field executionRunnerField =
reporter.getClass().getDeclaredField("executionUnitRunner");
executionRunnerField.setAccessible(true);
ExecutionUnitRunner executionUnitRunner = (ExecutionUnitRunner)
executionRunnerField.get(reporter);

Field cucumberScenarioField =
executionUnitRunner.getClass().getDeclaredField("cucumberScenario");
cucumberScenarioField.setAccessible(true);
CucumberScenario cucumberScenario = (CucumberScenario)
cucumberScenarioField.get(executionUnitRunner);

Field cucumberBackgroundField =
cucumberScenario.getClass().getDeclaredField("cucumberBackground");
cucumberBackgroundField.setAccessible(true);
CucumberBackground cucumberBackground = (CucumberBackground)
cucumberBackgroundField.get(cucumberScenario);

Field cucumberFeatureField =
cucumberBackground.getClass().getSuperclass().getDeclaredField("cucumberFeature");
cucumberFeatureField.setAccessible(true);
CucumberFeature cucumberFeature = (CucumberFeature)
cucumberFeatureField.get(cucumberBackground);

This will get you EVERYTHING from the executed feature. Name, tags,
Scenarios, Whatever you want.

Put this into an AFTER clause in any class you want and there you go. You
will have everything you ever wanted from your test case. Every bit of
information is in that cucumberFeature.

Enjoy your days in hell.

G.
Post by Gergely Brautigam
option unfortunately because Tagname is unknown and differs from story to
story obviously.
It's the title of the ticket. :)
G.
Post by Gergely Brautigam
Hi Aslak.
Because based on the Tag I'd like to perform a certain action for example
put it into a custom report.
I'd like to generate a report based on tags corresponding to JIRA issues
/ stories to have a view of how many tests there are for a ticket.
Sorry I might have tried to say Listener not filter. Like a listener for
jUnit test execution for example.
G.
Post by aslak hellesoy
Post by Gergely Brautigam
Hi guys.
I want to find out if it possible to get the annotations on a Feature
instead of a Scenario.
We call them tags, not annotations (just want to avoid confusion)
Post by Gergely Brautigam
contains the Annotation on a Scenario which I found after some digging.
However I can't seem to be able to find the name of the feature and
annotations on it.
@After
public static runAfterFeatures(Scenario sc) {
logger.log("These are the annotations on a feature: " +
sc.annotationsOnAFeature);
}
@Oneannotation @web @storynumber @quick
Feature: Do something interesting
And I would like to be able to get these annotations from it.
Why? What do you need it for?
Post by Gergely Brautigam
Do I have to implement my own filter for that?
What do you mean by filter? What API do you have in mind?
Aslak
Post by Gergely Brautigam
If so...where do I register the implementor with cucumber?
thanks very much!
Greg
--
-- 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
https://groups.google.com/d/forum/cukes?hl=en
---
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
For more options, visit https://groups.google.com/groups/opt_out.
--
-- 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/***@public.gmane.org To unsubscribe from this group, send email to cukes+***@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
---
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
aslak hellesoy
2013-04-15 19:26:57 UTC
Permalink
Post by Gergely Brautigam
Well if there is no other way... hacking it shall be...
Be patient. Allow a few days to wait for a response. After that, send a
reminder. We're all busy here.
Post by Gergely Brautigam
There you go, how is that for a solution?
Field f = scenario.getClass().getDeclaredField("reporter");
f.setAccessible(true);
JUnitReporter reporter = (JUnitReporter) f.get(scenario);
Field executionRunnerField =
reporter.getClass().getDeclaredField("executionUnitRunner");
executionRunnerField.setAccessible(true);
ExecutionUnitRunner executionUnitRunner =
(ExecutionUnitRunner) executionRunnerField.get(reporter);
Field cucumberScenarioField =
executionUnitRunner.getClass().getDeclaredField("cucumberScenario");
cucumberScenarioField.setAccessible(true);
CucumberScenario cucumberScenario = (CucumberScenario)
cucumberScenarioField.get(executionUnitRunner);
Field cucumberBackgroundField =
cucumberScenario.getClass().getDeclaredField("cucumberBackground");
cucumberBackgroundField.setAccessible(true);
CucumberBackground cucumberBackground = (CucumberBackground)
cucumberBackgroundField.get(cucumberScenario);
Field cucumberFeatureField =
cucumberBackground.getClass().getSuperclass().getDeclaredField("cucumberFeature");
cucumberFeatureField.setAccessible(true);
CucumberFeature cucumberFeature = (CucumberFeature)
cucumberFeatureField.get(cucumberBackground);
This will get you EVERYTHING from the executed feature. Name, tags,
Scenarios, Whatever you want.
Put this into an AFTER clause in any class you want and there you go. You
will have everything you ever wanted from your test case. Every bit of
information is in that cucumberFeature.
Enjoy your days in hell.
G.
an option unfortunately because Tagname is unknown and differs from story
to story obviously.
It's the title of the ticket. :)
G.
Post by Gergely Brautigam
Hi Aslak.
Because based on the Tag I'd like to perform a certain action for
example put it into a custom report.
I'd like to generate a report based on tags corresponding to JIRA issues
/ stories to have a view of how many tests there are for a ticket.
Sorry I might have tried to say Listener not filter. Like a listener for
jUnit test execution for example.
G.
Post by aslak hellesoy
Post by Gergely Brautigam
Hi guys.
I want to find out if it possible to get the annotations on a Feature
instead of a Scenario.
We call them tags, not annotations (just want to avoid confusion)
Post by Gergely Brautigam
contains the Annotation on a Scenario which I found after some digging.
However I can't seem to be able to find the name of the feature and
annotations on it.
@After
public static runAfterFeatures(Scenario sc) {
logger.log("These are the annotations on a feature: " +
sc.annotationsOnAFeature);
}
@Oneannotation @web @storynumber @quick
Feature: Do something interesting
And I would like to be able to get these annotations from it.
Why? What do you need it for?
Post by Gergely Brautigam
Do I have to implement my own filter for that?
What do you mean by filter? What API do you have in mind?
Aslak
Post by Gergely Brautigam
If so...where do I register the implementor with cucumber?
thanks very much!
Greg
--
-- 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<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
https://groups.google.com/d/**forum/cukes?hl=en<https://groups.google.com/d/forum/cukes?hl=en>
---
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
For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
.
--
-- 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
To unsubscribe from this group, send email to
https://groups.google.com/d/forum/cukes?hl=en
---
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/groups/opt_out.
--
-- 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/***@public.gmane.org To unsubscribe from this group, send email to cukes+***@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
---
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Gergely Brautigam
2013-04-16 07:40:49 UTC
Permalink
Ohh yes of course. No problem. I just didn't have the time to wait
unfortunately. :( BUT!! That doesn't mean I'm not awaiting some awesome
better solution!! :)

So definitely I'll wait. I just needed a temporary solution for as long as
I wait.

Thanks very much for all the help you can give me!

Gergely.
Post by aslak hellesoy
Post by Gergely Brautigam
Well if there is no other way... hacking it shall be...
Be patient. Allow a few days to wait for a response. After that, send a
reminder. We're all busy here.
Post by Gergely Brautigam
There you go, how is that for a solution?
Field f = scenario.getClass().getDeclaredField("reporter");
f.setAccessible(true);
JUnitReporter reporter = (JUnitReporter) f.get(scenario);
Field executionRunnerField =
reporter.getClass().getDeclaredField("executionUnitRunner");
executionRunnerField.setAccessible(true);
ExecutionUnitRunner executionUnitRunner =
(ExecutionUnitRunner) executionRunnerField.get(reporter);
Field cucumberScenarioField =
executionUnitRunner.getClass().getDeclaredField("cucumberScenario");
cucumberScenarioField.setAccessible(true);
CucumberScenario cucumberScenario = (CucumberScenario)
cucumberScenarioField.get(executionUnitRunner);
Field cucumberBackgroundField =
cucumberScenario.getClass().getDeclaredField("cucumberBackground");
cucumberBackgroundField.setAccessible(true);
CucumberBackground cucumberBackground = (CucumberBackground)
cucumberBackgroundField.get(cucumberScenario);
Field cucumberFeatureField =
cucumberBackground.getClass().getSuperclass().getDeclaredField("cucumberFeature");
cucumberFeatureField.setAccessible(true);
CucumberFeature cucumberFeature = (CucumberFeature)
cucumberFeatureField.get(cucumberBackground);
This will get you EVERYTHING from the executed feature. Name, tags,
Scenarios, Whatever you want.
Put this into an AFTER clause in any class you want and there you go. You
will have everything you ever wanted from your test case. Every bit of
information is in that cucumberFeature.
Enjoy your days in hell.
G.
an option unfortunately because Tagname is unknown and differs from story
to story obviously.
It's the title of the ticket. :)
G.
Post by Gergely Brautigam
Hi Aslak.
Because based on the Tag I'd like to perform a certain action for
example put it into a custom report.
I'd like to generate a report based on tags corresponding to JIRA
issues / stories to have a view of how many tests there are for a ticket.
Sorry I might have tried to say Listener not filter. Like a listener
for jUnit test execution for example.
G.
On Mon, Apr 15, 2013 at 12:22 PM, Gergely Brautigam <
Post by Gergely Brautigam
Hi guys.
I want to find out if it possible to get the annotations on a Feature
instead of a Scenario.
We call them tags, not annotations (just want to avoid confusion)
Post by Gergely Brautigam
contains the Annotation on a Scenario which I found after some digging.
However I can't seem to be able to find the name of the feature and
annotations on it.
@After
public static runAfterFeatures(Scenario sc) {
logger.log("These are the annotations on a feature: " +
sc.annotationsOnAFeature);
}
@Oneannotation @web @storynumber @quick
Feature: Do something interesting
And I would like to be able to get these annotations from it.
Why? What do you need it for?
Post by Gergely Brautigam
Do I have to implement my own filter for that?
What do you mean by filter? What API do you have in mind?
Aslak
Post by Gergely Brautigam
If so...where do I register the implementor with cucumber?
thanks very much!
Greg
--
-- 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<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
at https://groups.google.com/d/**forum/cukes?hl=en<https://groups.google.com/d/forum/cukes?hl=en>
---
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,
For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
.
--
-- 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
To unsubscribe from this group, send email to
group at https://groups.google.com/d/forum/cukes?hl=en
---
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/groups/opt_out.
--
-- 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/***@public.gmane.org To unsubscribe from this group, send email to cukes+***@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
---
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Karan
2013-12-27 05:50:05 UTC
Permalink
Hi,

I am getting error on the statement :
Field executionRunnerField =
reporter.getClass().getDeclaredField("executionUnitRunner");

that executionUnitRunner is empty..
From where do we get it.?? or do i need to write something else at its
place ??

Thanks
Well if there is no other way... hacking it shall be...
There you go, how is that for a solution?
Field f = scenario.getClass().getDeclaredField("reporter");
f.setAccessible(true);
JUnitReporter reporter = (JUnitReporter) f.get(scenario);
Field executionRunnerField =
reporter.getClass().getDeclaredField("executionUnitRunner");
executionRunnerField.setAccessible(true);
ExecutionUnitRunner executionUnitRunner =
(ExecutionUnitRunner) executionRunnerField.get(reporter);
Field cucumberScenarioField =
executionUnitRunner.getClass().getDeclaredField("cucumberScenario");
cucumberScenarioField.setAccessible(true);
CucumberScenario cucumberScenario = (CucumberScenario)
cucumberScenarioField.get(executionUnitRunner);
Field cucumberBackgroundField =
cucumberScenario.getClass().getDeclaredField("cucumberBackground");
cucumberBackgroundField.setAccessible(true);
CucumberBackground cucumberBackground = (CucumberBackground)
cucumberBackgroundField.get(cucumberScenario);
Field cucumberFeatureField =
cucumberBackground.getClass().getSuperclass().getDeclaredField("cucumberFeature");
cucumberFeatureField.setAccessible(true);
CucumberFeature cucumberFeature = (CucumberFeature)
cucumberFeatureField.get(cucumberBackground);
This will get you EVERYTHING from the executed feature. Name, tags,
Scenarios, Whatever you want.
Put this into an AFTER clause in any class you want and there you go. You
will have everything you ever wanted from your test case. Every bit of
information is in that cucumberFeature.
Enjoy your days in hell.
G.
an option unfortunately because Tagname is unknown and differs from story
to story obviously.
It's the title of the ticket. :)
G.
Post by Gergely Brautigam
Hi Aslak.
Because based on the Tag I'd like to perform a certain action for
example put it into a custom report.
I'd like to generate a report based on tags corresponding to JIRA issues
/ stories to have a view of how many tests there are for a ticket.
Sorry I might have tried to say Listener not filter. Like a listener for
jUnit test execution for example.
G.
Post by aslak hellesoy
Post by Gergely Brautigam
Hi guys.
I want to find out if it possible to get the annotations on a Feature
instead of a Scenario.
We call them tags, not annotations (just want to avoid confusion)
Post by Gergely Brautigam
contains the Annotation on a Scenario which I found after some digging.
However I can't seem to be able to find the name of the feature and
annotations on it.
@After
public static runAfterFeatures(Scenario sc) {
logger.log("These are the annotations on a feature: " +
sc.annotationsOnAFeature);
}
@Oneannotation @web @storynumber @quick
Feature: Do something interesting
And I would like to be able to get these annotations from it.
Why? What do you need it for?
Post by Gergely Brautigam
Do I have to implement my own filter for that?
What do you mean by filter? What API do you have in mind?
Aslak
Post by Gergely Brautigam
If so...where do I register the implementor with cucumber?
thanks very much!
Greg
--
-- 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
https://groups.google.com/d/forum/cukes?hl=en
---
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
For more options, visit https://groups.google.com/groups/opt_out.
--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
aslak hellesoy
2013-12-27 06:50:21 UTC
Permalink
Hi,
Field executionRunnerField = reporter.getClass().getDeclaredField("
executionUnitRunner");
that executionUnitRunner is empty..
From where do we get it.?? or do i need to write something else at its
place ??
Why are you trying to access this field? If we understood what you're
trying to achieve we could perhaps suggest an alternative.

Aslak
Thanks
Post by Gergely Brautigam
Well if there is no other way... hacking it shall be...
There you go, how is that for a solution?
Field f = scenario.getClass().getDeclaredField("reporter");
f.setAccessible(true);
JUnitReporter reporter = (JUnitReporter) f.get(scenario);
Field executionRunnerField = reporter.getClass().
getDeclaredField("executionUnitRunner");
executionRunnerField.setAccessible(true);
ExecutionUnitRunner executionUnitRunner =
(ExecutionUnitRunner) executionRunnerField.get(reporter);
Field cucumberScenarioField = executionUnitRunner.getClass()
.getDeclaredField("cucumberScenario");
cucumberScenarioField.setAccessible(true);
CucumberScenario cucumberScenario = (CucumberScenario)
cucumberScenarioField.get(executionUnitRunner);
Field cucumberBackgroundField = cucumberScenario.getClass().
getDeclaredField("cucumberBackground");
cucumberBackgroundField.setAccessible(true);
CucumberBackground cucumberBackground = (CucumberBackground)
cucumberBackgroundField.get(cucumberScenario);
Field cucumberFeatureField = cucumberBackground.getClass().
getSuperclass().getDeclaredField("cucumberFeature");
cucumberFeatureField.setAccessible(true);
CucumberFeature cucumberFeature = (CucumberFeature)
cucumberFeatureField.get(cucumberBackground);
This will get you EVERYTHING from the executed feature. Name, tags,
Scenarios, Whatever you want.
Put this into an AFTER clause in any class you want and there you go. You
will have everything you ever wanted from your test case. Every bit of
information is in that cucumberFeature.
Enjoy your days in hell.
G.
an option unfortunately because Tagname is unknown and differs from story
to story obviously.
It's the title of the ticket. :)
G.
Post by Gergely Brautigam
Hi Aslak.
Because based on the Tag I'd like to perform a certain action for
example put it into a custom report.
I'd like to generate a report based on tags corresponding to JIRA
issues / stories to have a view of how many tests there are for a ticket.
Sorry I might have tried to say Listener not filter. Like a listener
for jUnit test execution for example.
G.
On Mon, Apr 15, 2013 at 12:22 PM, Gergely Brautigam <
Post by Gergely Brautigam
Hi guys.
I want to find out if it possible to get the annotations on a Feature
instead of a Scenario.
We call them tags, not annotations (just want to avoid confusion)
Post by Gergely Brautigam
contains the Annotation on a Scenario which I found after some digging.
However I can't seem to be able to find the name of the feature and
annotations on it.
@After
public static runAfterFeatures(Scenario sc) {
logger.log("These are the annotations on a feature: " +
sc.annotationsOnAFeature);
}
@Oneannotation @web @storynumber @quick
Feature: Do something interesting
And I would like to be able to get these annotations from it.
Why? What do you need it for?
Post by Gergely Brautigam
Do I have to implement my own filter for that?
What do you mean by filter? What API do you have in mind?
Aslak
Post by Gergely Brautigam
If so...where do I register the implementor with cucumber?
thanks very much!
Greg
--
-- 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
at https://groups.google.com/d/forum/cukes?hl=en
---
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,
For more options, visit https://groups.google.com/groups/opt_out.
--
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/groups/opt_out.
--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
aslak hellesoy
2013-04-16 17:01:25 UTC
Permalink
Please don't top post. It's too hard to have an email discussion that way.
See Rule 2.
Post by Gergely Brautigam
Hi Aslak.
Because based on the Tag I'd like to perform a certain action for example
put it into a custom report.
So you're using hooks to write a report? That's what formatters/listeners
are for.

Hooks are designed to set up tear down state - not perform reporting.

Aslak
Post by Gergely Brautigam
I'd like to generate a report based on tags corresponding to JIRA issues /
stories to have a view of how many tests there are for a ticket.
Sorry I might have tried to say Listener not filter. Like a listener for
jUnit test execution for example.
G.
Post by aslak hellesoy
Post by Gergely Brautigam
Hi guys.
I want to find out if it possible to get the annotations on a Feature
instead of a Scenario.
We call them tags, not annotations (just want to avoid confusion)
Post by Gergely Brautigam
contains the Annotation on a Scenario which I found after some digging.
However I can't seem to be able to find the name of the feature and
annotations on it.
@After
public static runAfterFeatures(Scenario sc) {
logger.log("These are the annotations on a feature: " +
sc.annotationsOnAFeature);
}
@Oneannotation @web @storynumber @quick
Feature: Do something interesting
And I would like to be able to get these annotations from it.
Why? What do you need it for?
Post by Gergely Brautigam
Do I have to implement my own filter for that?
What do you mean by filter? What API do you have in mind?
Aslak
Post by Gergely Brautigam
If so...where do I register the implementor with cucumber?
thanks very much!
Greg
--
-- 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<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
https://groups.google.com/d/**forum/cukes?hl=en<https://groups.google.com/d/forum/cukes?hl=en>
---
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
For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
.
--
-- 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
To unsubscribe from this group, send email to
https://groups.google.com/d/forum/cukes?hl=en
---
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/groups/opt_out.
--
-- 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/***@public.gmane.org To unsubscribe from this group, send email to cukes+***@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
---
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Gergely Brautigam
2013-04-17 07:22:19 UTC
Permalink
Top post? I don't know what that is, I'll look into it.

Well see my first question then, which said how do I implement another
solution like a listener.

I even used the exact same word.

"Sorry I might have tried to say Listener not filter. Like a listener for
jUnit test execution for example.".
Post by aslak hellesoy
Please don't top post. It's too hard to have an email discussion that way.
See Rule 2.
Post by Gergely Brautigam
Hi Aslak.
Because based on the Tag I'd like to perform a certain action for example
put it into a custom report.
So you're using hooks to write a report? That's what formatters/listeners
are for.
Hooks are designed to set up tear down state - not perform reporting.
Aslak
Post by Gergely Brautigam
I'd like to generate a report based on tags corresponding to JIRA issues
/ stories to have a view of how many tests there are for a ticket.
Sorry I might have tried to say Listener not filter. Like a listener for
jUnit test execution for example.
G.
Post by aslak hellesoy
Post by Gergely Brautigam
Hi guys.
I want to find out if it possible to get the annotations on a Feature
instead of a Scenario.
We call them tags, not annotations (just want to avoid confusion)
Post by Gergely Brautigam
contains the Annotation on a Scenario which I found after some digging.
However I can't seem to be able to find the name of the feature and
annotations on it.
@After
public static runAfterFeatures(Scenario sc) {
logger.log("These are the annotations on a feature: " +
sc.annotationsOnAFeature);
}
@Oneannotation @web @storynumber @quick
Feature: Do something interesting
And I would like to be able to get these annotations from it.
Why? What do you need it for?
Post by Gergely Brautigam
Do I have to implement my own filter for that?
What do you mean by filter? What API do you have in mind?
Aslak
Post by Gergely Brautigam
If so...where do I register the implementor with cucumber?
thanks very much!
Greg
--
-- 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<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
https://groups.google.com/d/**forum/cukes?hl=en<https://groups.google.com/d/forum/cukes?hl=en>
---
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
For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
.
--
-- 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
To unsubscribe from this group, send email to
group at https://groups.google.com/d/forum/cukes?hl=en
---
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/groups/opt_out.
--
-- 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/***@public.gmane.org To unsubscribe from this group, send email to cukes+***@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
---
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Matt Wynne
2013-04-17 07:59:35 UTC
Permalink
Post by Gergely Brautigam
Top post? I don't know what that is, I'll look into it.
-- 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.
Rule 2 is about top-posting. Please read the linked article.

cheers,
Matt

--
http://mattwynne.net || https://twitter.com/mattwynne || http://the-cucumber-book.com || http://bddkickstart.com || http://www.relishapp.com
--
-- 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/***@public.gmane.org To unsubscribe from this group, send email to cukes+***@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
---
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Gergely Brautigam
2013-04-18 07:25:17 UTC
Permalink
Excellent. Thanks. However this still does not solve my problem. :)

As far as I could find I could only come up with listeners for ruby but not
the java version one. :(

So if there is a resource I maybe missed or something could you please
point me into the right direction? :)

Thanks!
G.
Post by Gergely Brautigam
Top post? I don't know what that is, I'll look into it.
-- Rules --
Post by Gergely Brautigam
1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/**
Posting_style#Interleaved_**style<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.
Rule 2 is about top-posting. Please read the linked article.
cheers,
Matt
--
http://mattwynne.net || https://twitter.com/mattwynne ||
http://the-cucumber-book.com || http://bddkickstart.com ||
http://www.relishapp.com
--
-- 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/***@public.gmane.org To unsubscribe from this group, send email to cukes+***@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
---
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Matt Wynne
2013-04-18 07:27:42 UTC
Permalink
Fixing Rule 2. Please stop breaking this rule, it's there for a reason.
Post by Matt Wynne
Post by Gergely Brautigam
Top post? I don't know what that is, I'll look into it.
-- 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.
Rule 2 is about top-posting. Please read the linked article.
Excellent. Thanks. However this still does not solve my problem. :)
As far as I could find I could only come up with listeners for ruby but not the java version one. :(
So if there is a resource I maybe missed or something could you please point me into the right direction? :)
Thanks!
cheers,
Matt

--
http://mattwynne.net || https://twitter.com/mattwynne || http://the-cucumber-book.com || http://bddkickstart.com || http://www.relishapp.com
--
-- 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/***@public.gmane.org To unsubscribe from this group, send email to cukes+***@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
---
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Gergely Brautigam
2013-04-18 09:45:01 UTC
Permalink
Post by Matt Wynne
Fixing Rule 2. Please stop breaking this rule, it's there for a reason.
Like this?
Post by Matt Wynne
Post by Gergely Brautigam
Top post? I don't know what that is, I'll look into it.
-- Rules --
Post by Gergely Brautigam
1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/**
Posting_style#Interleaved_**style<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.
Rule 2 is about top-posting. Please read the linked article.
Excellent. Thanks. However this still does not solve my problem. :)
As far as I could find I could only come up with listeners for ruby but
not the java version one. :(
So if there is a resource I maybe missed or something could you please
point me into the right direction? :)
Thanks!
cheers,
Matt
--
http://mattwynne.net || https://twitter.com/mattwynne ||
http://the-cucumber-book.com || http://bddkickstart.com ||
http://www.relishapp.com
--
-- 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/***@public.gmane.org To unsubscribe from this group, send email to cukes+***@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
---
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Continue reading on narkive:
Loading...