Tag: 黄瓜

运行单个function时,Cucumber无法找到步骤

我刚刚将黄瓜安装到一个新的rails项目中(第一次从头开始设置)并且在运行所有测试( bundle exec cucumber )时它运行得非常好,但是当我运行单个function文件时找不到任何步骤。 我怎么开始调试这个? rails (3.2.13) cucumber-rails (1.3.1) cucumber (>= 1.2.0) # file listing features/ ├── campaigns │ ├── donating_campaigns.feature │ └── viewing_campaigns.feature ├── step_definitions │ └── campaign_steps.rb └── support └── env.rb

“rake”运行我所有的Cucumber测试都很好,但“黄瓜”没有步骤

我inheritance了一个Rails(3)应用程序,并试图掌握现有的Cucumber测试。 我在应用程序的’features’文件夹中有以下设置(我错过了任何不相关的文件,例如额外的function和步骤) /features /people new-person.feature /step_definitions people_steps.rb web_steps.rb /support env.rb paths.rb selectors.rb 如果我运行’rake’,它会运行features / people / new-person.feature中的所有function,正确使用step_definitions中列出的步骤。 但是,我不想每次都运行rake因为它需要太长时间,我只想在Cucumber中运行特定的测试,例如cucumber features/people/new-person.feature -l 8 当我这样做时,它运行该function但尚未加载步骤。 我得到了回复: Using the default profile… Feature: Add a new person In order to allocate tasks to people As a community manager I want to add a new person Scenario: Secondary navigation should contain […]

黄瓜测试 – 获取RoutingError

怎么了,伙计们。 请帮忙。 当我运行我的黄瓜测试时,我遇到了这个错误: No route matches {:action=>”show”, :controller=>”accounts”} (ActionController::RoutingError) ./features/support/paths.rb:40:in `path_to’ 耙路线显示: account GET /accounts/:id(.:format) {:action=>”show”, :controller=>”accounts”} cucumber_test.feature Scenario: Given… And… Then i should be on Show page function/支持/ paths.rb when /^Show page$/ account_path @account 的routes.rb Myapp::Application.routes.draw do resources :accounts

Appium服务器因没有新命令而关闭

我在Windows机器上使用Appium for Android本机应用程序自动化。 我的所有场景都表现良好,但有时App崩溃了,Appium停止说“没有在60秒内获得新命令,关闭”。 注意 – 如果明确地按下键盘上的任何键,它将获得黄瓜执行时执行的下一个命令。 我可以看到Appium正在发送查找元素的请求,但是没有收到任何响应。 我不知道为什么会这样,但同样的事情大多没有任何问题。 当这个问题发生时,Appium会关闭应用程序,接下来的场景也会失败。 有人帮助解决此问题。 这是Appium服务器日志: 信息:启动应用程序 info:[debug]试图杀死所有’uiautomator’进程 info:[debug]使用’uiautomator’获取所有进程 info:[debug]执行cmd:C:\ Users \ PG106 \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s 300450adeedc3100 shell“ps’uiautomator’” info:[debug]找不到匹配的进程 info:[debug]运行bootstrap info:[debug]产生:C:\ Users \ PG106 \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s 300450adeedc3100 shell […]

Ruby on Rails:Cucumber:如何关注打开新窗口的链接?

我有一个在新窗口中打开的链接,我需要测试我的应用程序在该新窗口中的部分。 任何建议将不胜感激。

用黄瓜测试时,sql错误无法启动事务内的事务

我是黄瓜的新手,我正在学习BDD 当我尝试填写表单并创建记录时,会显示此sqlite错误,但是当我在浏览器中手动尝试代码时没有错误。 我正在使用rails 4。 这是我的控制器代码 class Admin::ItemsController < ApplicationController def index @items=Item.all end def new @item=Item.new end def create @item=Item.new items_params respond_to do |format| if @item.save format.html { redirect_to admin_items_path } else format.html { redirect_to new_admin_items_path } end end end private def items_params params.require(:item).permit(:name,:price) end end 这是我的function文件 Feature: Manage Items In order to make a […]

我应该何时在Cucumber和RSpec工作流程中单独测试视图?

经过一段时间的Cucumber和RSpec BDD,我意识到我的许多黄瓜function只是更高级别的视图测试。 当我开始编写我的场景然后转到RSpec时,我不会编写视图规范,因为我可以复制并粘贴部分场景,这将是丑陋的复制。 以这种情况为例 Scenario: New user comes to the site Given I am not signed in When I go to the home page Then I should see “Sign up free” 我知道这不是直接测试视图,但是编写单独的视图规范来检查同样的事情对我来说似乎是多余的。 我接近黄瓜错了吗? 我究竟应该在视图规格中测试什么? 我应该为每个视图编写它们,例如测试视图的操作 def show @project = current_user.projects.first end 或者我应该只测试更复杂的视图?

如何测试发布请求并跟随capybara重定向?

我正在尝试用水豚和黄瓜测试一个post请求。 我无法访问页面并按下链接发送请求,因为它有一个确认对话框,我没有使用javascript工作,所以我试图使用post方法,然后测试它是否重定向到适当的url但是我得到了: No response yet. Request a page first. (Rack::Test::Error) 我的代码是: page.driver.post url page.driver.status_code.should be 302 follow_redirect! 它一直很好,直到follow_redirect! 。 我试过了page.driver.follow_redirects! 但它也不起作用。 有帮助吗?

Capybara电子邮件重置会话

我需要在注册Capybara后测试一个特定的智能重定向流程。 假设我的网站上有几个interesting_pages ,我希望在确认注册后将用户重定向到上次访问过的有趣页面 小场景: When I visit the interesting page “42” And I visit a couple uninteresting pages # Note during the visit to other pages, session[:interesting_page] is correctly set to the url of page “42” When I sign up and I confirm via the link in the email # At this point I have […]

如何在Rails中使用Cucumber产生负面情况?

我有一个负面的方案来测试黄瓜。 具体来说,我想确保当有人发布带有无效句柄的URL时,该站点会返回错误。 我的场景看起来像: 场景:创建一个句柄太短的人当名为“Fred”的人处理“tooshort”更新然后我应该得到一个500错误 我的步骤看起来像 当/ ^名为“(。 )”的人用句柄“(。 )”更新$ / do | name,handle | 访问“/ mobile / update?handle =#{udid}&name =#{name}” 当我运行场景时,由于来自When的错误,它永远不会到达THEN部分 错误:无句柄(RuntimeError) 这是正确的,何时应该转500错误。 我只是不知道如何将当时作为否定测试。 也许我应该使用不同于什么时候的东西?