Class: Test
- Inherits:
-
Contextual::Node
- Object
- Contextual::Node
- Test
- Includes:
- Contextual::Child
- Defined in:
- lib/contextual/test.rb
Overview
A Test is an actionable unit of testing.
Instance Attribute Summary collapse
Attributes inherited from Contextual::Node
Instance Method Summary collapse
- #get_result(filter_settings) ⇒ TestResult
-
#initialize(title, assertions:, setup: nil, teardown: nil, action: nil, options: nil, skip: false) ⇒ Test
constructor
A new instance of Test.
-
#report ⇒ void
Report results, if any.
-
#should_run_with_filter(filter_settings) ⇒ Boolean
Should this run with the current filter settings.
Methods included from Contextual::Child
Methods inherited from Contextual::Node
#run, #run_setup, #run_teardown, #should_run_with_search_term
Constructor Details
#initialize(title, assertions:, setup: nil, teardown: nil, action: nil, options: nil, skip: false) ⇒ Test
Returns a new instance of Test.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/contextual/test.rb', line 21 def initialize( title, assertions:, setup: nil, teardown: nil, action: nil, options: nil, skip: false ) super(title, setup: setup, teardown: teardown, options: , skip: skip) @action = action @assertions = assertions @assert_failures = [] end |
Instance Attribute Details
#ran_successfully ⇒ Boolean
14 15 16 |
# File 'lib/contextual/test.rb', line 14 def ran_successfully @ran_successfully end |
Instance Method Details
#get_result(filter_settings) ⇒ TestResult
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/contextual/test.rb', line 65 def get_result(filter_settings) super @result = run_setup unless @result.nil? # Setup failed, we want to bail out as soon as possible @ran_successfully = false return @result end run_action run_assertions teardown_failure = run_teardown unless teardown_failure.nil? @ran_successfully = false @result = teardown_failure end # At this point, if nothing has failed, this test ran successfully @ran_successfully = true if @ran_successfully.nil? @result end |
#report ⇒ void
This method returns an undefined value.
Report results, if any
55 56 57 58 59 60 61 |
# File 'lib/contextual/test.rb', line 55 def report(*) @result.report(@parent_count) @assert_failures.each do |assert_failure| assert_failure.report(@parent_count) end end |
#should_run_with_filter(filter_settings) ⇒ Boolean
Should this run with the current filter settings
46 47 48 49 50 51 |
# File 'lib/contextual/test.rb', line 46 def should_run_with_filter(filter_settings) return filter_settings.testSearchFor == _title if filter_settings.hasTestSearchFor return _title.include? filter_settings.testFilterTerm if filter_settings.hasTestFilterTerm should_run_with_search_term(filter_settings) end |