Class: TestRunner::TestResult
- Inherits:
-
Object
- Object
- TestRunner::TestResult
- Defined in:
- lib/test-runner/test_result.rb
Instance Attribute Summary collapse
- #elapsed_time ⇒ Float readonly
- #script_results ⇒ Array<TestScriptResult> readonly
- #state_dir ⇒ String readonly
- #success ⇒ Boolean readonly
- #test ⇒ Test readonly
Class Method Summary collapse
Instance Method Summary collapse
- #expected_result? ⇒ Boolean
- #expected_to_fail? ⇒ Boolean
- #expected_to_succeed? ⇒ Boolean
- #failed? ⇒ Boolean
-
#initialize(test, script_results, success, elapsed_time, state_dir) ⇒ TestResult
constructor
A new instance of TestResult.
- #successful? ⇒ Boolean
- #to_h ⇒ Hash
- #to_json ⇒ Object
- #unexpected_result? ⇒ Boolean
Constructor Details
#initialize(test, script_results, success, elapsed_time, state_dir) ⇒ TestResult
Returns a new instance of TestResult.
20 21 22 23 24 25 26 |
# File 'lib/test-runner/test_result.rb', line 20 def initialize(test, script_results, success, elapsed_time, state_dir) @test = test @script_results = script_results @success = success && script_results.all?(&:expected_result?) @elapsed_time = elapsed_time @state_dir = state_dir end |
Instance Attribute Details
#elapsed_time ⇒ Float (readonly)
15 16 17 |
# File 'lib/test-runner/test_result.rb', line 15 def elapsed_time @elapsed_time end |
#script_results ⇒ Array<TestScriptResult> (readonly)
9 10 11 |
# File 'lib/test-runner/test_result.rb', line 9 def script_results @script_results end |
#state_dir ⇒ String (readonly)
18 19 20 |
# File 'lib/test-runner/test_result.rb', line 18 def state_dir @state_dir end |
#success ⇒ Boolean (readonly)
12 13 14 |
# File 'lib/test-runner/test_result.rb', line 12 def success @success end |
Class Method Details
.from_h(test, scripts_by_name, json) ⇒ TestResult
74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/test-runner/test_result.rb', line 74 def self.from_h(test, scripts_by_name, json) script_results = json.fetch('script_results').map do |sr| script = scripts_by_name.fetch(sr.fetch('script')) TestScriptResult.from_h(script, sr) end new( test, script_results, json.fetch('success'), json.fetch('elapsed_time'), json.fetch('state_dir') ) end |
Instance Method Details
#expected_result? ⇒ Boolean
36 37 38 39 40 41 42 |
# File 'lib/test-runner/test_result.rb', line 36 def expected_result? if test.expect_failure !@success else @success end end |
#expected_to_fail? ⇒ Boolean
52 53 54 |
# File 'lib/test-runner/test_result.rb', line 52 def expected_to_fail? test.expect_failure end |
#expected_to_succeed? ⇒ Boolean
48 49 50 |
# File 'lib/test-runner/test_result.rb', line 48 def expected_to_succeed? !test.expect_failure end |
#failed? ⇒ Boolean
32 33 34 |
# File 'lib/test-runner/test_result.rb', line 32 def failed? !@success end |
#successful? ⇒ Boolean
28 29 30 |
# File 'lib/test-runner/test_result.rb', line 28 def successful? @success end |
#to_h ⇒ Hash
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/test-runner/test_result.rb', line 57 def to_h { 'type' => 'test', 'test' => test.path, 'success' => successful?, 'expected_to_succeed' => expected_to_succeed?, 'expected_result' => expected_result?, 'elapsed_time' => elapsed_time, 'state_dir' => state_dir, 'script_results' => script_results.map(&:to_h) } end |
#to_json ⇒ Object
89 90 91 |
# File 'lib/test-runner/test_result.rb', line 89 def to_json(*) to_h.to_json(*) end |
#unexpected_result? ⇒ Boolean
44 45 46 |
# File 'lib/test-runner/test_result.rb', line 44 def unexpected_result? !expected_result? end |