-
Notifications
You must be signed in to change notification settings - Fork 554
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add feature tests for JSON formatter
- Loading branch information
Showing
4 changed files
with
249 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
@test_unit @config | ||
Feature: | ||
|
||
SimpleCov::Formatter::JSONFormatter is one of the | ||
formatters included by default, useful for exporting | ||
coverage results in JSON format. | ||
|
||
Background: | ||
Given I'm working on the project "faked_project" | ||
Scenario: With JSONFormatter | ||
Given SimpleCov for Test/Unit is configured with: | ||
""" | ||
require 'simplecov' | ||
require 'simplecov_json_formatter' | ||
SimpleCov.formatter = SimpleCov::Formatter::JSONFormatter | ||
SimpleCov.at_exit do | ||
puts SimpleCov.result.format! | ||
end | ||
SimpleCov.start do | ||
add_group 'Libs', 'lib/faked_project/' | ||
end | ||
""" | ||
|
||
When I successfully run `bundle exec rake test` | ||
Then a JSON coverage report should have been generated in "coverage" | ||
And the output should contain "JSON Coverage report generated" | ||
|
||
Scenario: When CC_TEST_REPORTER_ID is set in the environment | ||
Given SimpleCov for Test/Unit is configured with: | ||
""" | ||
ENV['CC_TEST_REPORTER_ID'] = "9719ac886877886b7e325d1e828373114f633683e429107d1221d25270baeabf" | ||
require 'simplecov' | ||
SimpleCov.at_exit do | ||
puts SimpleCov.result.format! | ||
end | ||
SimpleCov.start do | ||
add_group 'Libs', 'lib/faked_project/' | ||
end | ||
""" | ||
|
||
When I successfully run `bundle exec rake test` | ||
Then a JSON coverage report should have been generated in "coverage" | ||
And the output should contain "JSON Coverage report generated" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
Then /^the JSON coverage report should map:/ do |expected_report| | ||
cd(".") do | ||
json_report = File.open("coverage/coverage.json").read | ||
expected_report = ERB.new(expected_report).result(binding) | ||
expect(json_report).to eq(expected_report) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters