Discussion:
[Cucumber] Cuke JVM Scen Outline: Accessing current Scenario Outline row in the @Before hook in Cucumber-JVM
(too old to reply)
b***@qualityhabit.com
2018-04-04 22:37:25 UTC
Permalink
Hi all,

Can anyone point me to the right way to access current scenario outline row
in the @Before hook in cucumber jvm? I'm looking to store an integration
synchronization key there and would like to expose it in a common test
context rather than wait for the step file to access it. Cucumber
1.2.5/Gherkin 2.12.2 had something like this available through a Scenario
ID hack, but having trouble finding the same in current Cucumber
2.4.0/Gherkin 5.0.0 release.

I did look through code and samples before posting and had found that the
Pickle.class seems to have rendered this by the time "runPickle()" of the
Runner.class is executed, but you have to know what step renders it, and
you have to know what text to look for (not to mention kluge your way to
that data). I was hoping it would be available directly in the
Scenario.class, but this seems to have been removed or changed at some
point since the 2.0.0 Cucumber release.

I'm currently investigating something along the lines of below and then
using that to access fields inside the class that renders the Examples row
during execution..
private static Object getPrivateField(Object subject, String fieldName)
throws NoSuchFieldException, IllegalAccessException {
Field f = subject.getClass().getDeclaredField(fieldName);
f.setAccessible(true);
return f.get(subject);
}

Any help would be much appreciated!
Brian Brewer
--
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.
Loading...