Skip to content

Commit

Permalink
Fixing bug causing potentially unrelated image to be included in test…
Browse files Browse the repository at this point in the history
… reports
  • Loading branch information
Simone Civetta committed Jun 24, 2014
1 parent abd233d commit f867cf3
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 1 deletion.
Binary file added features/assets/apple_raw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion features/html_report.feature
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,11 @@ Feature: Creating a HTML test report
And the test suite has finished
And I have a screenshot in the output folder
When I pipe to xcpretty with "--report html --screenshots"
Then I should see a screenshot in HTML
Then I should see a screenshot in HTML

Scenario: Preventing unrelated images to be included in final report
Given I have a passing test in my suite
And the test suite has finished
And I have an unrelated image in the output folder
When I pipe to xcpretty with "--report html --screenshots"
Then I should not see a screenshot in HTML
4 changes: 4 additions & 0 deletions features/steps/formatting_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@
copy_file_to_screenshot_dir(SAMPLE_SCREENSHOT_FILE)
end

Given(/^I have an unrelated image in the output folder/) do
copy_file_to_screenshot_dir(SAMPLE_UNRELATED_IMAGE_FILE)
end

Then(/^I should see text beginning with "(.*?)"$/) do |text|
run_output.lines.to_a.detect {|line| line.start_with? text }.should_not be_nil
end
Expand Down
4 changes: 4 additions & 0 deletions features/steps/html_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@
Then(/^I should see a screenshot in HTML$/) do
html_report_body.get_elements("//*[contains(@class, 'screenshot')]/").to_a.size.should_not == 0
end

Then(/^I should not see a screenshot in HTML$/) do
html_report_body.get_elements("//*[contains(@class, 'screenshot')]/").to_a.size.should == 0
end
1 change: 1 addition & 0 deletions lib/xcpretty/reporters/html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def find_test_suite(image_name)
@test_suites.each do |key, value|
return key if image_name.start_with?(key)
end
nil
end
end
end
1 change: 1 addition & 0 deletions spec/fixtures/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -545,3 +545,4 @@
SAMPLE_CLANG_ERROR = 'clang: error: linker command failed with exit code 1 (use -v to see invocation)'

SAMPLE_SCREENSHOT_FILE = 'RACCommandSpec, line 80, hello xcpretty.png'
SAMPLE_UNRELATED_IMAGE_FILE = 'apple_raw.png'

0 comments on commit f867cf3

Please sign in to comment.