cucumber-jvm

How to get scenario name from a scenario outline in cucumber using java

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 10:08:33
问题 Suppose I have a test case like - *Scenario: Facebook login test GIVEN I am a Facebook user WHEN I enter my user name & password THEN login should be successful* How could I get the scenario name from the step definition methods corresponding to "I am a Facebook user" or "I enter my user name & password" or "login should be successful" ? Step definitions methods are - @Given("^I am a Facebook user$") public void method1() { //some coding //I want to get the scenario name here } @When("^I

IntelliJ IDEA not recognizing .feature files

混江龙づ霸主 提交于 2019-12-09 11:20:55
问题 I have installed the cucumber-java and gherkin plugins in IntelliJ IDEA but when I create a .feature file it is not recognized as a feature file. I did restart IntelliJ and have checked to make sure the plugins are enabled in the plugins settings window.feature file in IntelliJ 回答1: If you have Substeps IntelliJ Plugin enabled then that might be the issue. you will need to remove and restart. 回答2: Check Settings->Editor->File Types. Verify that Cucumber Scenario is set to a Registered Pattern

How do I create a Cucumber DataTable?

旧时模样 提交于 2019-12-09 10:10:08
问题 I want to manually set up a Cucumber DataTable using Java (instead of Gherkin). In Gherkin, my table would look like this: | h1 | h2 | | v1 | v2 | My Java so far looks like this: List<String> raw = Arrays.asList( "v1", "v2"); DataTable dataTable = DataTable.create(raw, Locale.getDefault(), "h1", "h2"); What I get back is a DataTable with headers but no contents. It's also longer than expected: | h1| h2 | | | | | | | I'm sure the solution must be fairly simple, but I'm a bit at a loss right

Is there a way to directly generate Step Definitions in Eclipse without Running Cucumber?

蹲街弑〆低调 提交于 2019-12-09 07:57:13
问题 Im doing integration testing with cucumber and Gradle in Eclipse. For now my workflow is Write a feature file Run it to generate step skeletons Copy and implement them This works good for new features and so on, but becomes quite bothersome if you have a large feature and implement new steps in the middle or towards the end. To get the new step skeletons I need to run the whole feature. Even with the dryRun = true option this takes up a long time. I have heard that IntellyJ can generate these

Is it possible to skip a scenario with Cucumber-JVM at run-time

对着背影说爱祢 提交于 2019-12-09 06:20:18
问题 I want to add a tag @skiponchrome to a scenario, this should skip the scenario when running a Selenium test with the Chrome browser. The reason to-do this is because some scenario's work in some environments and not in others, this might not even be browser testing specific and could be applied in other situation for example OS platforms. Example hook: @Before("@skiponchrome") // this works public void beforeScenario() { if(currentBrowser == 'chrome') { // this works // Skip scenario code

Cucumber feature files are not executed using Maven

安稳与你 提交于 2019-12-08 12:17:43
问题 Hi I have setUp a Java project using Maven in eclipse. I am facing an issue whenever I am trying to run the script. Its is executed by the not opening the desired website which I am parsing from the feature file. Please have a look to the following code and Image of my directories setup in eclipse Here is my code for PageStepsDefs.java package com.workshop.airport.workshop.airport; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import cucumber.api.java

How to convert cucumber.api.Datable to List<MyClass> with more than 2 col in datatable

一世执手 提交于 2019-12-08 11:19:43
问题 Gherkin Statement is : And Instruments,Shareprice,Quantities to be added are |name |sal |address| |xyz |100 |Greek | |abc |200 |Italy | Step def is : @Given("My emp details are $") public void my_emp_details_are(DataTable arg1) throws Throwable { List<EMP> lstemp= arg1.asList(EMP.class); } Exception Generated: cucumber.runtime.CucumberException: No such field datastructure.EMP.emps EMP is Class with 3 fields: Hey i am new to Java I have seen asList() Documentation i didnt understand public

How to make jenkins build pass if cucumber scenarios pass percentage is 80%

爱⌒轻易说出口 提交于 2019-12-08 10:54:19
问题 How to make jenkins build pass if cucumber JVM scenarios pass percentage is 80% 回答1: The cucumber reports plugin can be used for this. The plugin has a lot of options where the build is marked as failure or unstable. For example: failedScenariosPercentage (optional) Maximum percentage of failed scenarios above which build result is changed. 来源: https://stackoverflow.com/questions/57084429/how-to-make-jenkins-build-pass-if-cucumber-scenarios-pass-percentage-is-80

How to skip all cucumber-jvm scenarios when first scenario is failed

空扰寡人 提交于 2019-12-08 07:37:50
问题 I have 8 cucumber-jvm scenarios and the very first scenario measures the page load time and environment availability. In order to avoid unnecessary runs, if the first scenario is failed - for instance, the environment is not available, or loading too slowly - all other scenarios should be skipped. How can I do that? My CucumberOptions : @RunWith(Cucumber.class) @CucumberOptions( strict = true, features = {"src/test/resources/features"}, glue = {"stepDefinitions"}, format = { "progress", "html

picocontainer for singleton DI

泄露秘密 提交于 2019-12-08 04:36:05
问题 I'm trying to use picocontainer for DI but still getting my shared object instantiated several times instead of being automatically managed as a singleton. Here's an example to illustrate. Classes ASteps and BSteps receive a SharedObject instance through their constructors. I expected it to be managed as a singleton by picocontainer: instantiated only once, as per the Cucumber docs. Instead, I see it gets instantiated once for ASteps and once for BSteps: Running my.domain.CucumberRunTest INFO