On Monday, 23 December 2013 at 19:43, Brian Jackson wrote:
I'm trying to use cucumber-jvm with SauceLabs. I'm initializing the RemoteWebDriver but I can't find a way to lookup the name of the test that is currently executing, ideally a descriptive name that captures the feature, scenario, and any example data that is being used. Is it possible to get that info, for example in the @Before method, in cucumber-jvm at this 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+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
On Monday, 23 December 2013 at 19:43, Brian Jackson wrote:
I'm trying to use cucumber-jvm with SauceLabs. I'm initializing the RemoteWebDriver but I can't find a way to lookup the name of the test that is currently executing, ideally a descriptive name that captures the feature, scenario, and any example data that is being used. Is it possible to get that info, for example in the @Before method, in cucumber-jvm at this time?You can declare a cucumber.api.Scenario parameter in the before hook, and Cucumber will pass you one.Why do you need to get the metadata?
@Before public void initSelenium(Scenario scenario) throws Exception {
// TODO: Find the scenario name
String scenarioName = ((ExecutionUnitRunner)getPrivateField(getPrivateField(scenario, "reporter"), "executionUnitRunner")).getName();
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("version", "5"); capabilities.setCapability("platform", Platform.XP); capabilities.setCapability("name", scenarioName); this.driver = new RemoteWebDriver(
new URL("http://"+authentication.getUsername()+":"+authentication.getAccessKey()+"@ondemand.saucelabs.com:80/wd/hub"), capabilities); }
private static Object getPrivateField(Object subject, String fieldName) throws NoSuchFieldException, IllegalAccessException { Field f = subject.getClass().getDeclaredField(fieldName); f.setAccessible(true); return f.get(subject); }
On Monday, 23 December 2013 at 19:43, Brian Jackson wrote:
I'm trying to use cucumber-jvm with SauceLabs. I'm initializing the RemoteWebDriver but I can't find a way to lookup the name of the test that is currently executing, ideally a descriptive name that captures the feature, scenario, and any example data that is being used. Is it possible to get that info, for example in the @Before method, in cucumber-jvm at this time?You can declare a cucumber.api.Scenario parameter in the before hook, and Cucumber will pass you one.Why do you need to get the metadata?Aslak
On Monday, December 23, 2013 3:31:26 PM UTC-5, Aslak Hellesøy wrote:
On Monday, 23 December 2013 at 19:43, Brian Jackson wrote:
I'm trying to use cucumber-jvm with SauceLabs. I'm initializing the RemoteWebDriver but I can't find a way to lookup the name of the test that is currently executing, ideally a descriptive name that captures the feature, scenario, and any example data that is being used. Is it possible to get that info, for example in the @Before method, in cucumber-jvm at this time?You can declare a cucumber.api.Scenario parameter in the before hook, and Cucumber will pass you one.Why do you need to get the metadata?AslakI need the scenario name to set the "name" Capability on the RemoteWebDriver so that my SauceLabs tests have a nice name. Below is an excerpt of the hack I have so far, but its not great for several reasons. For example in a Scenario Outline it only includes the Example text and not the name of the Scenario Outline or Feature. I'd like that all concatenated together so on SauceLabs I can see the Feature/Scenario Outline/Example that was run for a particular execution.
Is there a possibility to expose the scenario metadata in the Before and After hooks?Here is our use case.Our scenarios are bit complex and not possible to hard code setup/test data in step definitions.So basically we want to read the test data based on the scenario name, feature, tag e.t.c(We understand Gherkin does not enforce unique feature/scenario names, but we can follow coding standards to keep it unique )We really need this information.In addition to the above we want to run our tests from cli.Unfortunately the above hack is not working when running from cli.The "reporter" field as null in Before, After hooks.We kind of stuck.Thanks-Ramesh Kapa
On Monday, January 13, 2014 4:30:05 AM UTC-5, Björn Rasmusson wrote:Brian Jackson wrote:On Monday, December 23, 2013 3:31:26 PM UTC-5, Aslak Hellesøy wrote:
On Monday, 23 December 2013 at 19:43, Brian Jackson wrote:
I'm trying to use cucumber-jvm with SauceLabs. I'm initializing the RemoteWebDriver but I can't find a way to lookup the name of the test that is currently executing, ideally a descriptive name that captures the feature, scenario, and any example data that is being used. Is it possible to get that info, for example in the @Before method, in cucumber-jvm at this time?You can declare a cucumber.api.Scenario parameter in the before hook, and Cucumber will pass you one.Why do you need to get the metadata?AslakI need the scenario name to set the "name" Capability on the RemoteWebDriver so that my SauceLabs tests have a nice name. Below is an excerpt of the hack I have so far, but its not great for several reasons. For example in a Scenario Outline it only includes the Example text and not the name of the Scenario Outline or Feature. I'd like that all concatenated together so on SauceLabs I can see the Feature/Scenario Outline/Example that was run for a particular execution.