cucumber-jvm

Specify the feature file location in cucumber

谁说我不能喝 提交于 2019-12-01 05:14:24
I have created some cucumber test steps and a small Cucumber test case, which I run with JUnit like so: @RunWith(Cucumber.class) public class FuelCarTest { //executs cucumber steps in the class FuelCarSteps } The Cucumber features files are now automatically loaded from the classpath location, src/main/resources/<package-name>/*.feature I could like to know how I can tell cucumber the location of my feature files, because I need it to load them from a location outside the classpath (e.g. data//). I found the solution, there is the @Cucumber.Options annotation, among setting the report output

How to get an ActionContext from Struts 2 during acceptance tests?

谁说我不能喝 提交于 2019-11-30 23:15:15
I am writing acceptance tests (testing the behavior) using cucumber-jvm, on an application with Struts 2 and Tomcat as my Servlet Container. At some point in my code, I need to fetch the user from the Struts 2 HttpSession , created by an HttpServletRequest . Since I'm doing tests and not running Tomcat, I don't have an active session and I get a NullPointerException . Here's the code I need to call: public final static getActiveUser() { return (User) getSession().getAttribute("ACTIVE_USER"); } And the getSession method: public final static HttpSession getSession() { final HttpServletRequest

Take a screenshot with Cucumber

放肆的年华 提交于 2019-11-30 16:35:35
I just learn how to use cucumber. Can you tell me how to complete this code? You can implement step definitions for undefined steps with these snippets: Then /^I take a screenshot$/ do pending # express the regexp above with the code you wish you had end Screenshots in general are taken when something unexpected occurs. You may also want to capture a screenshot to report when a test case fails. In this particular case, you should have screenshot capture logic in an @After method that will be executed for every scenario. A Java, selenium version, @After("@browser") public void tearDown(Scenario

Any got Spring Boot working with cucumber-jvm?

谁都会走 提交于 2019-11-30 15:05:50
问题 I'm using spring boot as it removes all the boring stuff and let's me focus on my code, but all the test examples use junit and I want to use cucumber? Can someone point me in the right direction to get cucumber and spring to start things up, do all the auto config and wiring and let my step definitions use auto wired beans to do stuff? 回答1: Try to use the following on your step definition class: @ContextConfiguration(classes = YourBootApplication.class, loader =

How to pass variable values between steps in Cucumber Java?

爷,独闯天下 提交于 2019-11-30 14:20:56
问题 I have a variable and I want to pass this variable across all the steps. Anyone can suggest with an code snippet example please on how to pass a variable value between the steps please. Any help will be highly appreciated. 回答1: In Cucumber for Java (cucumber-jvm) the intended way of sharing data between steps is to use a dependency integration (DI) container - several of which have been integrated with Cucumber. The method in which you use DI varies slightly from container to container, but

Cucumber options annotation

可紊 提交于 2019-11-30 13:44:23
问题 The cucumber-jvm javadocs states that purpose of the glue element is to specify the location of the stepdefinitions and hooks. However, this doesn't seem to work for me. Lets say I have my features in directory a, and my step definitions in directory b. Then, @Cucumber.Options( features= "directory_a", glue="directory_b" ) will load my feature files from directory_a, but, it doesn't load my step definitions from directly_b. However, if I use @Cucumber.Options( features= {"directory_a",

Any got Spring Boot working with cucumber-jvm?

耗尽温柔 提交于 2019-11-30 13:02:31
I'm using spring boot as it removes all the boring stuff and let's me focus on my code, but all the test examples use junit and I want to use cucumber? Can someone point me in the right direction to get cucumber and spring to start things up, do all the auto config and wiring and let my step definitions use auto wired beans to do stuff? Petter Holmström Try to use the following on your step definition class: @ContextConfiguration(classes = YourBootApplication.class, loader = SpringApplicationContextLoader.class) @RunWith(SpringJUnit4ClassRunner.class) public class MySteps { //... } Also make

Cucumber Test a Spring Boot Application

£可爱£侵袭症+ 提交于 2019-11-30 12:33:44
问题 Does anyone know where I can find a sample application where Cucumber is used to test a Spring Boot application through Gradle? I can run the tests fine starting the server on the cmd line and using my IDE, but I need to be able to run them all programmatically on the CI server. I saw the answer on here but that solution did not work for me, most likely because I have multiple step def files. Here is my setup build.grade (Mentioned in the other question) testCompile ("org.springframework.boot

Dcucumber.options, how to have multiple tags

孤街醉人 提交于 2019-11-30 11:52:48
问题 I am trying run cucumber tests using maven with following command mvn test -Dcucumber.options="--tag @debug1" This command works fine, however if i try something like following, i get error mvn test -Dcucumber.options="--tag @debug1 @debug2" Is there a way to pass in multiple tag names with cucumber run-time options? 回答1: To run scenarios with @debug1 and @debug2 : mvn test -Dcucumber.options="--tags @debug1 --tags @debug2" To run scenarios with @debug1 or @debug2 : mvn test -Dcucumber

How to pass variable values between steps in Cucumber Java?

偶尔善良 提交于 2019-11-30 10:01:16
I have a variable and I want to pass this variable across all the steps. Anyone can suggest with an code snippet example please on how to pass a variable value between the steps please. Any help will be highly appreciated. In Cucumber for Java (cucumber-jvm) the intended way of sharing data between steps is to use a dependency integration (DI) container - several of which have been integrated with Cucumber. The method in which you use DI varies slightly from container to container, but here's an example using PicoContainer: // MySharedData.java public class MySharedData { public String