cucumber-jvm

Reusing Cucumber-JVM step definitions in other projects

大兔子大兔子 提交于 2019-12-03 00:35:29
How can I reuse Cucumber-JVM Step Definitions in other projects to test some typical web actions. The point is that I've created some java project just with Step Definition Implementations of the typical scenario actions like: When I follow the link "*some_link*" Then I should see following content "*some_content*" on page And I want to reuse these definitions in other projects (include in classpath), just to write their own simple scenarios. But when I run the scenario (as JUnit test), Cucumber cant find Step Definitions. And when I try to extend Step Definitions class it gives me an error,

Can I use spring to autowire controller in cucumber test?

喜夏-厌秋 提交于 2019-12-02 20:47:32
I am using Cucumber to automate the testing of services and controllers in my app. In addition, I am using the Cucumber Junit runner @RunWith(Cucumber.class) in the test steps. I need to instantiate my controller and was wondering if I could use Spring to autowire this. The code below shows what I want to do. public class MvcTestSteps { //is it possible to do this ???? @Autowired private UserSkillsController userSkillsController; /* * Opens the target browser and page objects */ @Before public void setup() { //insted of doing it like this??? userSkillsController = (UserSkillsController)

What is the cucumber-jvm equivalent of Cucumber.wants_to_quit?

这一生的挚爱 提交于 2019-12-02 19:43:45
问题 I am writing tests using cucumber-jvm and I want the system to stop running tests on the first scenario that fails. I found example code written for Cucumber Ruby that does this via an After hook. I am searching for the correct java class and method to call that will be the equivalent of setting Cucumber.wants_to_quit = true in Ruby. Here is my example code: @After public void quitOnErrors(Scenario scenario) { if (scenario.isFailed()) { // Need the correct class/method/property to call here.

Cucumber how to find if a feature file has executed? Any Java method?

淺唱寂寞╮ 提交于 2019-12-02 02:46:22
@Before public void quit_if_tagged_scenario_failed(Scenario scenario) { if (!isTagged(scenario) && prevScenarioFailed) throw new IllegalStateException("An important scenario has failed! Cucumber wants to quit."); } I'm using this method to check if the previuos scenario failed. If failed I want to skip all the scenarios in that feature file.So the problem here is if I’m running two feature files the last scenario in the feature file failed and the first step of next feature will also fails because cucumbers previous scenario from past feature file is failed. Do you know how to handle that kind

Reading parameter values from Testng.xml file in cucumber stepdefs

前提是你 提交于 2019-12-01 23:29:43
问题 I'm able to run testng scripts upon integrating with cucumber. I've followed the exact steps defined in http://automatictester.co.uk/2015/06/11/basic-cucumberjvm-selenium-webdriver-test-automation-framework/ link. Now I’ve one more requirement. can you explain me how to read values from parameters tag of testng.xml. See below example: <test name="ascentis.LoginDemo.Firefox"> <parameter name="BrowserName" value="Firefox" /> <parameter name="Environment" value="local" /> <packages> <package

Extracting Cucumber Step name at runtime

≯℡__Kan透↙ 提交于 2019-12-01 19:19:30
I am trying to find out if there is an option to figure out the cucumber step currently getting executed, I am trying to perform certain action depending on the step name. I can see StepDefinitionMatch class gets the steps, but I am not sure how can I access the steps at runtime. Any help? Adding a snapshot of the call stack if that helps. public StepDefinitionMatch(List<Argument> arguments, StepDefinition stepDefinition, String featurePath, Step step, LocalizedXStreams localizedXStreams) { super(arguments, stepDefinition.getLocation(false)); this.stepDefinition = stepDefinition; this

Extracting Cucumber Step name at runtime

帅比萌擦擦* 提交于 2019-12-01 17:57:40
问题 I am trying to find out if there is an option to figure out the cucumber step currently getting executed, I am trying to perform certain action depending on the step name. I can see StepDefinitionMatch class gets the steps, but I am not sure how can I access the steps at runtime. Any help? Adding a snapshot of the call stack if that helps. public StepDefinitionMatch(List<Argument> arguments, StepDefinition stepDefinition, String featurePath, Step step, LocalizedXStreams localizedXStreams) {

Does if else concept available in feature file (Gherkin language)?

孤街浪徒 提交于 2019-12-01 17:54:26
Is there anyway where we can use if/else concept in feature file? For example: Scenario: User should be able to check login page Given I am on login page When I click on SignIn button Then I should be in home page If yes Then I will create a new profile Else Then I will logout from page Not that I am aware of. Gherkin (and cucumber) are best used when they specify discreet business cases though, and should be repeatable, else they get hard to follow and test. It looks like you have two stories here at least: Scenario: A new user should be asked to sign in Given I am a new user And I navigate

Geb + Cucumber: Restart Browser Between Scenarios

余生颓废 提交于 2019-12-01 13:05:00
I'm using Grails 2.1.1 with Cucumber and Geb. I have an Auth.feature that contains 2 scenarios. One is for authenticating successfully and the other is for testing invalid credentials. The way I think I have to work this out is to have geb log out the user from the first scenario before it can run the second scenario. This is because my Given step checks to make sure I'm at the login page. After scenario 1 executes, I'm on a Dashboard page. I guess my question is do I (a) use geb to sign out the valid user before completing the scenario or (b) is there a way to have it start over between

Geb + Cucumber: Restart Browser Between Scenarios

坚强是说给别人听的谎言 提交于 2019-12-01 09:43:51
问题 I'm using Grails 2.1.1 with Cucumber and Geb. I have an Auth.feature that contains 2 scenarios. One is for authenticating successfully and the other is for testing invalid credentials. The way I think I have to work this out is to have geb log out the user from the first scenario before it can run the second scenario. This is because my Given step checks to make sure I'm at the login page. After scenario 1 executes, I'm on a Dashboard page. I guess my question is do I (a) use geb to sign out