Class: XCPretty::Reporter
- Defined in:
- lib/xcpretty/reporters/reporter.rb
Direct Known Subclasses
Constant Summary collapse
- FILEPATH =
'build/reports/tests.txt'
Constants inherited from Formatter
Formatter::ASCII_ERROR, Formatter::ASCII_WARNING, Formatter::ERROR, Formatter::WARNING
Constants included from FormatMethods
Constants included from ANSI
ANSI::COLORS, ANSI::EFFECT, ANSI::FORMATTED_MATCHER
Instance Attribute Summary collapse
-
#tests ⇒ Object
readonly
Returns the value of attribute tests.
Attributes inherited from Formatter
Attributes included from ANSI
Instance Method Summary collapse
- #finish ⇒ Object
- #format_failing_test(suite, test_case, reason, file) ⇒ Object
- #format_passing_test(suite, test_case, time) ⇒ Object
- #format_pending_test(classname, test_case) ⇒ Object
- #handle(line) ⇒ Object
-
#initialize(options) ⇒ Reporter
constructor
A new instance of Reporter.
- #load_dependencies ⇒ Object
- #write_report ⇒ Object
Methods inherited from Formatter
#format_compile_error, #format_compile_warning, #format_duplicate_symbols, #format_error, #format_file_missing_error, #format_ld_warning, #format_other, #format_test_summary, #format_undefined_symbols, #format_will_not_be_code_signed, #optional_newline, #pretty_format, #use_unicode?
Methods included from FormatMethods
#format_aggregate_target, #format_analyze, #format_analyze_target, #format_build_target, #format_check_dependencies, #format_clean, #format_clean_remove, #format_clean_target, #format_codesign, #format_compile, #format_compile_command, #format_compile_error, #format_compile_storyboard, #format_compile_warning, #format_compile_xib, #format_copy_header_file, #format_copy_plist_file, #format_copy_strings_file, #format_cpresource, #format_duplicate_symbols, #format_error, #format_file_missing_error, #format_generate_dsym, #format_ld_warning, #format_libtool, #format_linking, #format_measuring_test, #format_other, #format_pbxcp, #format_phase_script_execution, #format_phase_success, #format_preprocess, #format_process_info_plist, #format_process_pch, #format_process_pch_command, #format_shell_command, #format_test_run_finished, #format_test_run_started, #format_test_suite_started, #format_test_summary, #format_tiffutil, #format_touch, #format_undefined_symbols, #format_warning, #format_write_auxiliary_files, #format_write_file
Methods included from ANSI
#ansi_parse, #applied_effects, #colorize?, #cyan, #green, #red, #strip, #white, #yellow
Constructor Details
#initialize(options) ⇒ Reporter
Returns a new instance of Reporter.
15 16 17 18 19 20 21 22 |
# File 'lib/xcpretty/reporters/reporter.rb', line 15 def initialize() super(true, true) load_dependencies @filepath = [:path] || self.class::FILEPATH @test_count = 0 @fail_count = 0 @tests = [] end |
Instance Attribute Details
#tests ⇒ Object (readonly)
Returns the value of attribute tests.
6 7 8 |
# File 'lib/xcpretty/reporters/reporter.rb', line 6 def tests @tests end |
Instance Method Details
#finish ⇒ Object
28 29 30 31 |
# File 'lib/xcpretty/reporters/reporter.rb', line 28 def finish FileUtils.mkdir_p(File.dirname(@filepath)) write_report end |
#format_failing_test(suite, test_case, reason, file) ⇒ Object
33 34 35 36 37 |
# File 'lib/xcpretty/reporters/reporter.rb', line 33 def format_failing_test(suite, test_case, reason, file) @test_count += 1 @fail_count += 1 @tests.push("#{test_case} in #{file} FAILED: #{reason}") end |
#format_passing_test(suite, test_case, time) ⇒ Object
39 40 41 42 |
# File 'lib/xcpretty/reporters/reporter.rb', line 39 def format_passing_test(suite, test_case, time) @test_count += 1 @tests.push("#{test_case} PASSED") end |
#format_pending_test(classname, test_case) ⇒ Object
44 45 46 47 |
# File 'lib/xcpretty/reporters/reporter.rb', line 44 def format_pending_test(classname, test_case) @test_count += 1 @tests.push("#{test_case} IS PENDING") end |
#handle(line) ⇒ Object
24 25 26 |
# File 'lib/xcpretty/reporters/reporter.rb', line 24 def handle(line) @parser.parse(line) end |
#load_dependencies ⇒ Object
8 9 10 11 12 13 |
# File 'lib/xcpretty/reporters/reporter.rb', line 8 def load_dependencies unless @@loaded ||= false require 'fileutils' @@loaded = true end end |
#write_report ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/xcpretty/reporters/reporter.rb', line 49 def write_report File.open(@filepath, 'w') do |f| # WAT: get rid of these locals. BTW Cucumber fails if you remove them output_string = @tests.join("\n") output_string += "\nFINISHED RUNNING #{@test_count} TESTS WITH #{@fail_count} FAILURES" f.write output_string end end |