我是rails的新手,并开始了一个新项目.我有rspec2和黄瓜与我的测试工作没有问题.但是,如果我尝试添加guard-rspec和guard-cucumber,则会导致我的规范和集成测试失败.虽然,即使安装了防护装置,如果我手动运行rspec和黄瓜,测试都会成功.
我添加到我的gemfile:
gem 'guard-rspec'
gem 'guard-cucumber'
gem 'growl', :require => false if RUBY_PLATFORM =~ /darwin/i
gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i
Run Code Online (Sandbox Code Playgroud)
我跑了:
bundle
guard init rspec
guard init cucumber
Run Code Online (Sandbox Code Playgroud)
然后,当我跑卫,我得到rspec失败:
Failures:
1) PostsController GET index assigns all posts as @posts
Failure/Error: assigns(:posts).should eq([post])
expected [#<Post id: 14, title: "Title", body: "The body must be over 50 characters long, or else i...", created_at: "2011-08-16 09:02:26", updated_at: "2011-08-17 19:02:46">]
got [#<Post id: 1, title: "Title", body: "The body must …
Run Code Online (Sandbox Code Playgroud) 我是ROR的新手.我使用的是Ruby 1.9.2p290,rvm 1.10.2,chromedriver version = 18.0.995.0.
当我通过执行命令运行黄瓜测试时:
捆绑exec黄瓜功能/ mytest.feature
我收到了以下错误消息:
(::)失败的步骤(::)
proxy必须是字典类型,而不是null.收到:null
(硒:: webdriver的::错误:: WebDriverError)
我的步骤定义已失控.
他们无处不在!我可能有很多步骤做同样的事情.
我认为它甚至会减慢我的黄瓜功能,使其运行得更快.
帮助我需要一些好的指导!
什么是控制我们称之为"坏代码"的野兽的最佳方式.
我正在寻找一种可重复使用的技术,我可以一遍又一遍地使用,直到我的功能和步骤再次清晰干净.
我正在使用watir-cucumber进行测试自动化。我单独编写了以下方法.rb
,该方法不在步骤定义中。
def has_logged_in?
$browser.text.should include("t788")
end
Run Code Online (Sandbox Code Playgroud)
当我从步骤定义中调用此方法时,就会出现此错误,
wrong argument type String (expected Module) (TypeError)
Run Code Online (Sandbox Code Playgroud)
相同的代码在步骤定义中效果很好。我四处搜索,发现该include
方法用于包含模块,但这是ruby-include
method并should include
在下面rspec\expectations
。因此,如何在should include
上述步骤定义之外调用方法。我在Linux上使用watir-cucumber
我正试图让黄瓜测试在无头的centOS盒子上运行.我已经安装了Xvfb,firefox和我的测试套件,它们在我们的无头(头?)机器上运行.
版本
CentOS: 6.2
firefox: 23.0.1
headless: 1.0.1
selenium-webdriver: 2.35.0
watir-webdriver: 0.6.4
ruby: 1.9.3
Run Code Online (Sandbox Code Playgroud)
在irb:
1.9.3-p448 :001 > require 'watir-webdriver'
=> true
1.9.3-p448 :002 > require 'headless'
=> true
1.9.3-p448 :004 > headless = Headless.new
=> #<Headless:0x000000025e0860 @display=99, @autopick_display=true, @reuse_display=true, @dimensions="1280x1024x24", @video_capture_options={}, @destroy_at_exit=true>
1.9.3-p448 :005 > headless.start
=> #<Proc:0x000000025e5180@/usr/local/rvm/gems/ruby-1.9.3-p448/gems/headless-1.0.1/lib/headless.rb:175>
1.9.3-p448 :006 > b = Watir::Browser.new(:firefox)
Selenium::WebDriver::Error::WebDriverError: unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055)
from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.35.0/lib/selenium/webdriver/firefox/launcher.rb:79:in `connect_until_stable'
from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.35.0/lib/selenium/webdriver/firefox/launcher.rb:37:in `block in launch'
from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.35.0/lib/selenium/webdriver/firefox/socket_lock.rb:20:in `locked'
from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.35.0/lib/selenium/webdriver/firefox/launcher.rb:32:in `launch' …
Run Code Online (Sandbox Code Playgroud) 我使用Java进行硒自动化时,我有一个场景,仅当我针对当前场景手动关闭chrome浏览器时,才需要移至黄瓜功能文件中的下一个场景。
请帮我实现这个
我有这样的黄瓜stepdef
Given the date of <date>
When blah blah
Then x y and z
Examples:
|2015-01-01|
|2045-01-01|
Run Code Online (Sandbox Code Playgroud)
当我从中生成stepdefs时,我得到@Given("^the date of (\\d+)-(\\d+)-(\\d+)$")
And该方法是使用三个整数作为参数生成的。如何告诉Cucumber将其视为Java.Time LocalDate?有没有办法创建一个Cucumber会理解的映射器?或者至少,有一种方法可以将该日期对象视为字符串而不是三个数字?
我是YAML的新手,我正在尝试编写一些语言翻译测试.我的想法是我有一个YAML文件,其中包含相同文本的英语和威尔士语版本.我想知道如何在YAML中的字符串中使用正则表达式?
例:
我有这个基本测试:
#Gherkin
And I expect to see payment confirmation for "Dave"
#Step Def
And /^I expect to see payment confirmation for "(.*?)"$/ do |user|
expect(page).to have_text "Payment successful for #{user} - Reference: 000000"
end
Run Code Online (Sandbox Code Playgroud)
YAML参赛作品:
"Payment successful for Dave reference: 000000"
- welsh: "Taliad llwyddiannus ar gyfer Dave Cyfeirnod: 000000"
Run Code Online (Sandbox Code Playgroud)
我可以在该YAML条目中参数化Dave,因为测试套件涵盖了数百个用户.
谢谢
我一直在努力使它起作用。
我想建立一个测试运行器类,像这样
但是我得到这个错误:
错误:(3,26)Java:包 Cucumber.api.junit 不存在
错误:(10,10)Java:找不到符号
符号:类Cucumber
该类如下所示:
package nl.prvgld.sigma.aanvraagtitels.testutil;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
public class RunFeature {
}
Run Code Online (Sandbox Code Playgroud)
Pom.xml看起来像:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<modelVersion>4.0.0</modelVersion>
<groupId>nl.prvgld.sigma.aanvraagtitels</groupId>
<artifactId>Aanvraagtitels</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>Aanvraagtitels</name>
<url>http://maven.apache.org</url>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java8</artifactId>
<version>1.2.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-core -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<!-- …
Run Code Online (Sandbox Code Playgroud) 我一直在尝试使用JavaScript框架进行自动化测试,其中之一就是testCafe。我已经能够建立一个简单的TestCafe项目并为我的应用程序运行一些测试用例。但是,现在的要求是内置一些BDD支持。我在GitHub上查找了一些testCafe-cucumber集成项目,但无法运行它们。这是我尝试过的一些方法:
1)https://github.com/rquellh/testcafe-cucumber- 我克隆了存储库,-安装了npm,-使用“ npm test”运行测试用例,-启动空白浏览器,但测试未运行。我在VS代码控制台中看到此错误:
× Before # features\support\hooks.js:46
Error: function timed out, ensure the promise resolves within 20000 milliseconds
at Timeout._onTimeout (C:\Users\Mo\Desktop\TestCafe\github\testCafeBDD\testcafe-cucumber\node_modules\cucumber\src\user_code_runner.js:61:18)
at ontimeout (timers.js:482:11)
at tryOnTimeout (timers.js:317:5)
at Timer.listOnTimeout (timers.js:277:5)
× After # features\support\hooks.js:60
ReferenceError: testController is not defined
Run Code Online (Sandbox Code Playgroud)
然后我尝试了另一个gitHub项目,即这个项目:https : //github.com/kiwigrid/gherkin-testcafe
自述文件中的运行命令对我不起作用,甚至无法识别“ gherkin-testcafe”。
当我运行没有黄瓜的TestCafe测试用例时,我的package.json中有这一行
"scripts": {
"test": "testcafe chrome Tests/ -e --proxy https.proxy.mycompany.com:8000"
},
Run Code Online (Sandbox Code Playgroud)
之所以提到该代理,是因为我位于代理之后,没有该代理,浏览器将启动,但不会运行任何测试用例。我在testCafe网站上找到此修复程序
我猜(不确定)这可能也是黄瓜整合的问题。这些框架都不起作用,因为它们没有在任何地方设置代理。有人可以指出我正确的方向吗?如果需要设置代理,那么它需要在框架中的哪个位置进行操作-一个示例会有所帮助吗?