![](/img/trans.png)
[英]Rails 4 & SimpleCov: lib/tasks/cucumber.rake included in coverage report for SimpleCov?
[英]Cucumber test results not showing up in SimpleCov report
編輯:我現在用的是.simplecov
文件在我的目錄中每SimpleCov方向的根源。 我還添加了一些團體,包括“應用/視圖”。 但是,黃瓜測試仍未登錄到SimpleCov。 我甚至用launchy寶石,看是否執行代碼,這是......我有點在這一點難倒。
我正在嘗試第一次將Cucumber集成到我的Rails 5應用程序中。 我也使用RSpec的和SimpleCov。 我正在使用Cucumber測試簡單的用戶注冊和用戶登錄功能。 該測試通過了Cucumber的測試,並被告知我為Cucumber生成了一份Coverage報告。 但是,覆蓋率報告實際上並未顯示任何“登錄”或“注冊”功能。
user.feature文件:
# /features/user.feature
Feature: User Features
As a user I want to be able to Sign Up or Log In when I visit the home page so that I can use the website.
Scenario: Create a user account
When I go to the index
Then I should see "Sign Up"
Scenario: Sign In as a user
When I go to the index
Then I should see "Sign In"
user_steps.rb文件:
# /features/step_definitions/user_steps.rb
When(/^I go to the index$/) do
visit root_path
end
Then(/^I should see "([^"]*)"$/) do |arg1|
click_on "Sign Up"
fill_in "Email", with: "user1@example.com"
fill_in "Password", with: "password1"
fill_in "Password confirmation", with: "password1"
click_button "Sign up"
expect(page).to have_content("Welcome! You have signed up successfully.")
end
從運行終端輸出$ cucumber
表現出來的傳球:
ANTONIOs-MacBook-Pro:reddit_clone Tony$ cucumber
Using the default profile...
Feature: Create User
As a user I want to be able to sign up when I visit the home page so that they can use the website.
Scenario: Create a user account # features/user.feature:4
When I go to the index # features/step_definitions/user_steps.rb:1
Then I should see "Sign Up" # features/step_definitions/user_steps.rb:5
Scenario: Sign In as a user # features/user.feature:8
When I go to the index # features/step_definitions/user_steps.rb:1
Then I should see "Sign In" # features/step_definitions/user_steps.rb:5
2 scenarios (2 passed)
4 steps (4 passed)
0m0.897s
Coverage report generated for Cucumber Features to /Users/Tony/Documents/projects/rails/reddit_clone/coverage. 18 / 185 LOC (9.73%) covered.
我的承保范圍報告:
# /spec/spec_helper.rb top of the file.
require 'simplecov'
SimpleCov.start
require 'database_cleaner'
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation)
end
config.around(:each) do |example|
DatabaseCleaner.cleaning do
example.run
end
end
...
end
黃瓜env.rb文件:
# /features/support/env.rb
require 'simplecov'
SimpleCov.start 'rails'
require 'cucumber/rails'
我需要采取什么步驟才能在覆蓋率報告中顯示黃瓜測試的覆蓋率?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.