cucumber

Cucumber regex step definition

一笑奈何 提交于 2020-01-25 02:46:23
问题 Can someone explain what is the difference between @When("some text (.*)") and @When("^some text ([^\"]*)$") ? The former worked when using a straightforward step, but when using a data table it maps only to the first table item. 回答1: Here is explanation of couple of common regex : .* matches anything (or nothing), literally “any character (except a newline) 0 or more times” .+ matches at least one of anything [0-9] or d matches a series of digits (or nothing) [0-9]+ or d+ matches one or more

Test class not found in selected project

拈花ヽ惹草 提交于 2020-01-24 09:00:06
问题 Currently I am developing a simple program using Cucumber that will test logging in of a user on a website. Here is my TestRunner file: package cucumberTest; import org.junit.runner.RunWith; import cucumber.api.CucumberOptions; import cucumber.api.junit.Cucumber; @RunWith(Cucumber.class) @CucumberOptions(features = "Feature") public class TestRunner { } I also have the cucumber file as LogIn_Test.feature as follows: Feature: Login Action Scenario: Successful Login with Valid Credentials Given

Cucumber-jvm Hooks when Scenario is passed or failed

霸气de小男生 提交于 2020-01-24 04:19:06
问题 In Jbehave we can execute method upon outcome of scenario success/failure. One of the below mentioned methods will execute after failure and success. @AfterScenario(uponOutcome=AfterScenario.Outcome.SUCCESS) public void afterSuccessfulScenario() { // Some code to execute... } @AfterScenario(uponOutcome=AfterScenario.Outcome.FAILURE) public void afterFailedScenario() { // Some code to execute... } I'm trying to achieve the same thing in Cucumber-jvm . The scenario Hooks @Before and @After will

cucumber/ruby: possible to output the “puts” to a --format html file?

本小妞迷上赌 提交于 2020-01-21 11:44:01
问题 I've got some ruby tests that are calling different modules, classes where they detail what they're doing with some "puts" commands during execution. If you run those tests in the console then you will see the output of the "puts" command in the console but if you run the tests with the option: ruby --format html --output file.html then all that information is lost. Is there a way to log simple string messages inside the HTML report? 回答1: I tried the following steps: When /^I do something$/

cucumber/ruby: possible to output the “puts” to a --format html file?

半世苍凉 提交于 2020-01-21 11:42:37
问题 I've got some ruby tests that are calling different modules, classes where they detail what they're doing with some "puts" commands during execution. If you run those tests in the console then you will see the output of the "puts" command in the console but if you run the tests with the option: ruby --format html --output file.html then all that information is lost. Is there a way to log simple string messages inside the HTML report? 回答1: I tried the following steps: When /^I do something$/

Selenium doesn't work with Cucumber/Capybara (out of the box) - MacOSX

安稳与你 提交于 2020-01-21 05:03:21
问题 I'm having trouble trying to get a cucumber example to run under selenium. I'm running Rails3 Cucumber 0.10.0 Capybara 0.4.1.2 Reading the doco on https://github.com/jnicklas/capybara, it would appear that all that I need to get an example to run under selenium is to do the following: Step 1: Prefix the scenario with @javascript @javascript Scenario: User does x ... Step 2: Configure env.rb to tell capybara which driver to use: Capybara.javascript_driver = :selenium When I run: bundle exec

Using cucumber with staging database without truncation and transactions

不打扰是莪最后的温柔 提交于 2020-01-17 06:58:32
问题 We have a Ruby on Rails 2.3.8 project, where data are almost exclusively read only. We would like to write acceptance tests which use staging database (copy of the production database) So we do not want to use transactions or truncation of the database tables before or after features and scenarios. Is it possible? 回答1: My solution was to switch DatabaseCleaner to transaction cleaning strategy in features/support/env.rb if defined?(ActiveRecord::Base) begin require 'database_cleaner'

How to run mvn cucumber test using jar file?

烂漫一生 提交于 2020-01-16 19:42:26
问题 I have created a test automation framework using maven and cucumber. 1) I want to create a jar file which includes everything (all project files) 2) Then I want to run a test from the command line using above created jar like using the command ( mvn clean test -Dcucumber.options='--tags @all' ) I don't want to use the main method or anything. 回答1: java -Dcucumber.options="--tags @all" -jar your-test-jar.jar Try this. Although I am not sure why you don't want to use the main method. If you don

How do I convert a string into a reference to a variable in Ruby?

北慕城南 提交于 2020-01-16 10:53:53
问题 I need to be able to pass the name of a variable into an expression (in cucumber) and would like to be able to convert that string into a reference (i.e. not a copy) of the variable. e.g. Given /^I have set an initial value to @my_var$/ do @my_var = 10 end # and now I want to change the value of that variable in a different step Then /^I update "([^"]*)"$/ do |var_name_string| # I know I can get the value of @my_var by doing: eval "@my_var_copy = @#{var_name_string}" # But then once I update

How do I convert a string into a reference to a variable in Ruby?

ε祈祈猫儿з 提交于 2020-01-16 10:53:40
问题 I need to be able to pass the name of a variable into an expression (in cucumber) and would like to be able to convert that string into a reference (i.e. not a copy) of the variable. e.g. Given /^I have set an initial value to @my_var$/ do @my_var = 10 end # and now I want to change the value of that variable in a different step Then /^I update "([^"]*)"$/ do |var_name_string| # I know I can get the value of @my_var by doing: eval "@my_var_copy = @#{var_name_string}" # But then once I update