Class: Cucumber::Query
- Inherits:
-
Object
- Object
- Cucumber::Query
- Defined in:
- lib/cucumber/query.rb
Instance Method Summary collapse
-
#count_test_cases_started ⇒ Object
TODO: find****By methods (16/25) Complete Missing: findLocationOf (1 variant) - This strictly speaking isn’t a findBy but is located within them Missing: findSuggestionsBy (2 variants) Missing: findUnambiguousStepDefinitionBy (1 variant) Missing: findTestStepFinishedAndTestStepBy (1 variant) Missing: findMostSevereTestStepResultBy (2 variants) Missing: findAttachmentsBy (2 variants) Missing: findTestCaseDurationBy (2 variant) Missing: findLineageBy (9 variants!) To Review: findTestRunDuration (1 variant) - This strictly speaking isn’t a findBy but is located within them Complete: findMeta (1 variant) Complete: findTestRunHookStartedBy (1 variant) Complete: findTestRunHookFinishedBy (1 variant) Complete: findPickleStepBy (1 variant) Complete: findStepDefinitionsBy (1 variant) Complete: findStepBy (1 variant) Complete: findTestRunFinished (1 variant) Complete: findTestRunStarted (1 variant) Fully Complete (2/2): findTestStepsStartedBy (2 variants) Fully Complete (2/2): findTestStepBy (2 variants) Fully Complete (3/3): findTestCaseStartedBy (3 variants) Fully Complete (1/1): findTestCaseFinishedBy (1 variant) Fully Complete (4/4): findTestCaseBy (4 variants) Fully Complete (5/5): findPickleBy (5 variants) Fully Complete (3/3): findHookBy (3 variants) Fully Complete (2/2): findTestStepsFinishedBy (2 variants).
- #find_all_pickle_steps ⇒ Object
- #find_all_pickles ⇒ Object
- #find_all_step_definitions ⇒ Object
-
#find_all_test_case_finished ⇒ Object
This finds all test cases that have finished AND will not be retried.
-
#find_all_test_case_started ⇒ Object
This finds all test cases from the following conditions (UNION) -> Test cases that have started, but not yet finished -> Test cases that have started, finished, but that will NOT be retried.
- #find_all_test_cases ⇒ Object
- #find_all_test_run_hook_finished ⇒ Object
- #find_all_test_run_hook_started ⇒ Object
- #find_all_test_step_finished ⇒ Object
- #find_all_test_step_started ⇒ Object
- #find_all_test_steps ⇒ Object
-
#find_hook_by(message) ⇒ Object
This method will be called with 1 of these 3 messages [TestStep || TestRunHookStarted || TestRunHookFinished].
- #find_meta ⇒ Object
-
#find_pickle_by(message) ⇒ Object
This method will be called with 1 of these 5 messages [TestCase || TestCaseStarted || TestCaseFinished || TestStepStarted || TestStepFinished].
-
#find_pickle_step_by(test_step) ⇒ Object
This method will be called with only 1 message [TestStep].
-
#find_step_by(pickle_step) ⇒ Object
This method will be called with only 1 message [PickleStep].
-
#find_step_definitions_by(test_step) ⇒ Object
This method will be called with only 1 message [TestStep].
-
#find_test_case_by(message) ⇒ Object
This method will be called with 1 of these 4 messages [TestCaseStarted || TestCaseFinished || TestStepStarted || TestStepFinished].
-
#find_test_case_finished_by(test_case_started) ⇒ Object
This method will be called with only 1 message [TestCaseStarted].
-
#find_test_case_started_by(message) ⇒ Object
This method will be called with 1 of these 3 messages [TestCaseFinished || TestStepStarted || TestStepFinished].
- #find_test_run_duration ⇒ Object
- #find_test_run_finished ⇒ Object
-
#find_test_run_hook_finished_by(test_run_hook_started) ⇒ Object
This method will be called with only 1 message [TestRunHookStarted].
-
#find_test_run_hook_started_by(test_run_hook_finished) ⇒ Object
This method will be called with only 1 message [TestRunHookFinished].
- #find_test_run_started ⇒ Object
-
#find_test_step_by(message) ⇒ Object
This method will be called with 1 of these 2 messages [TestStepStarted || TestStepFinished].
-
#find_test_steps_finished_by(message) ⇒ Object
This method will be called with 1 of these 2 messages [TestCaseStarted || TestCaseFinished].
-
#find_test_steps_started_by(message) ⇒ Object
This method will be called with 1 of these 2 messages [TestCaseStarted || TestCaseFinished].
-
#initialize(repository) ⇒ Query
constructor
A new instance of Query.
Constructor Details
#initialize(repository) ⇒ Query
Returns a new instance of Query.
15 16 17 |
# File 'lib/cucumber/query.rb', line 15 def initialize(repository) @repository = repository end |
Instance Method Details
#count_test_cases_started ⇒ Object
TODO: find****By methods (16/25) Complete
Missing: findLocationOf (1 variant) - This strictly speaking isn't a findBy but is located within them
Missing: findSuggestionsBy (2 variants)
Missing: findUnambiguousStepDefinitionBy (1 variant)
Missing: findTestStepFinishedAndTestStepBy (1 variant)
Missing: findMostSevereTestStepResultBy (2 variants)
Missing: findAttachmentsBy (2 variants)
Missing: findTestCaseDurationBy (2 variant)
Missing: findLineageBy (9 variants!)
To Review: findTestRunDuration (1 variant) - This strictly speaking isn't a findBy but is located within them
Complete: findMeta (1 variant)
Complete: findTestRunHookStartedBy (1 variant)
Complete: findTestRunHookFinishedBy (1 variant)
Complete: findPickleStepBy (1 variant)
Complete: findStepDefinitionsBy (1 variant)
Complete: findStepBy (1 variant)
Complete: findTestRunFinished (1 variant)
Complete: findTestRunStarted (1 variant)
Fully Complete (2/2): findTestStepsStartedBy (2 variants)
Fully Complete (2/2): findTestStepBy (2 variants)
Fully Complete (3/3): findTestCaseStartedBy (3 variants)
Fully Complete (1/1): findTestCaseFinishedBy (1 variant)
Fully Complete (4/4): findTestCaseBy (4 variants)
Fully Complete (5/5): findPickleBy (5 variants)
Fully Complete (3/3): findHookBy (3 variants)
Fully Complete (2/2): findTestStepsFinishedBy (2 variants)
52 53 54 |
# File 'lib/cucumber/query.rb', line 52 def count_test_cases_started find_all_test_case_started.length end |
#find_all_pickle_steps ⇒ Object
60 61 62 |
# File 'lib/cucumber/query.rb', line 60 def find_all_pickle_steps repository.pickle_step_by_id.values end |
#find_all_pickles ⇒ Object
56 57 58 |
# File 'lib/cucumber/query.rb', line 56 def find_all_pickles repository.pickle_by_id.values end |
#find_all_step_definitions ⇒ Object
64 65 66 |
# File 'lib/cucumber/query.rb', line 64 def find_all_step_definitions repository.step_definition_by_id.values end |
#find_all_test_case_finished ⇒ Object
This finds all test cases that have finished AND will not be retried
79 80 81 |
# File 'lib/cucumber/query.rb', line 79 def find_all_test_case_finished repository.test_case_finished_by_test_case_started_id.values.reject(&:will_be_retried) end |
#find_all_test_case_started ⇒ Object
This finds all test cases from the following conditions (UNION)
-> Test cases that have started, but not yet finished
-> Test cases that have started, finished, but that will NOT be retried
71 72 73 74 75 76 |
# File 'lib/cucumber/query.rb', line 71 def find_all_test_case_started repository.test_case_started_by_id.values.select do |test_case_started| test_case_finished = find_test_case_finished_by(test_case_started) test_case_finished.nil? || !test_case_finished.will_be_retried end end |
#find_all_test_cases ⇒ Object
83 84 85 |
# File 'lib/cucumber/query.rb', line 83 def find_all_test_cases repository.test_case_by_id.values end |
#find_all_test_run_hook_finished ⇒ Object
91 92 93 |
# File 'lib/cucumber/query.rb', line 91 def find_all_test_run_hook_finished repository.test_run_hook_finished_by_test_run_hook_started_id.values end |
#find_all_test_run_hook_started ⇒ Object
87 88 89 |
# File 'lib/cucumber/query.rb', line 87 def find_all_test_run_hook_started repository.test_run_hook_started_by_id.values end |
#find_all_test_step_finished ⇒ Object
99 100 101 |
# File 'lib/cucumber/query.rb', line 99 def find_all_test_step_finished repository.test_steps_finished_by_test_case_started_id.values.flatten end |
#find_all_test_step_started ⇒ Object
95 96 97 |
# File 'lib/cucumber/query.rb', line 95 def find_all_test_step_started repository.test_steps_started_by_test_case_started_id.values.flatten end |
#find_all_test_steps ⇒ Object
103 104 105 |
# File 'lib/cucumber/query.rb', line 103 def find_all_test_steps repository.test_step_by_id.values end |
#find_hook_by(message) ⇒ Object
This method will be called with 1 of these 3 messages
[TestStep || TestRunHookStarted || TestRunHookFinished]
109 110 111 112 113 114 115 116 117 118 |
# File 'lib/cucumber/query.rb', line 109 def find_hook_by() (, i[test_step test_run_hook_started test_run_hook_finished], '#find_hook_by') if .is_a?(Cucumber::Messages::TestRunHookFinished) = find_test_run_hook_started_by() ? find_hook_by() : nil else repository.hook_by_id[.hook_id] end end |
#find_meta ⇒ Object
120 121 122 |
# File 'lib/cucumber/query.rb', line 120 def repository. end |
#find_pickle_by(message) ⇒ Object
This method will be called with 1 of these 5 messages
[TestCase || TestCaseStarted || TestCaseFinished || TestStepStarted || TestStepFinished]
126 127 128 129 130 131 |
# File 'lib/cucumber/query.rb', line 126 def find_pickle_by() (, i[test_case test_case_started test_case_finished test_step_started test_step_finished], '#find_pickle_by') = .is_a?(Cucumber::Messages::TestCase) ? : find_test_case_by() repository.pickle_by_id[.pickle_id] end |
#find_pickle_step_by(test_step) ⇒ Object
This method will be called with only 1 message
[TestStep]
135 136 137 138 139 |
# File 'lib/cucumber/query.rb', line 135 def find_pickle_step_by(test_step) (test_step, i[test_step], '#find_pickle_step_by') repository.pickle_step_by_id[test_step.pickle_step_id] end |
#find_step_by(pickle_step) ⇒ Object
This method will be called with only 1 message
[PickleStep]
143 144 145 146 147 |
# File 'lib/cucumber/query.rb', line 143 def find_step_by(pickle_step) (pickle_step, i[pickle_step], '#find_step_by') repository.step_by_id[pickle_step.ast_node_ids.first] end |
#find_step_definitions_by(test_step) ⇒ Object
This method will be called with only 1 message
[TestStep]
151 152 153 154 155 156 |
# File 'lib/cucumber/query.rb', line 151 def find_step_definitions_by(test_step) (test_step, i[test_step], '#find_step_definitions_by') ids = test_step.step_definition_ids.nil? ? [] : test_step.step_definition_ids ids.map { |id| repository.step_definition_by_id[id] }.compact end |
#find_test_case_by(message) ⇒ Object
This method will be called with 1 of these 4 messages
[TestCaseStarted || TestCaseFinished || TestStepStarted || TestStepFinished]
160 161 162 163 164 165 |
# File 'lib/cucumber/query.rb', line 160 def find_test_case_by() (, i[test_case_started test_case_finished test_step_started test_step_finished], '#find_test_case_by') = .is_a?(Cucumber::Messages::TestCaseStarted) ? : find_test_case_started_by() repository.test_case_by_id[.test_case_id] end |
#find_test_case_finished_by(test_case_started) ⇒ Object
This method will be called with only 1 message
[TestCaseStarted]
177 178 179 180 181 |
# File 'lib/cucumber/query.rb', line 177 def find_test_case_finished_by(test_case_started) (test_case_started, i[test_case_started], '#find_test_case_finished_by') repository.test_case_finished_by_test_case_started_id[test_case_started.id] end |
#find_test_case_started_by(message) ⇒ Object
This method will be called with 1 of these 3 messages
[TestCaseFinished || TestStepStarted || TestStepFinished]
169 170 171 172 173 |
# File 'lib/cucumber/query.rb', line 169 def find_test_case_started_by() (, i[test_case_finished test_step_started test_step_finished], '#find_test_case_started_by') repository.test_case_started_by_id[.test_case_started_id] end |
#find_test_run_duration ⇒ Object
183 184 185 186 187 188 189 |
# File 'lib/cucumber/query.rb', line 183 def find_test_run_duration if repository.test_run_started.nil? || repository.test_run_finished.nil? nil else (repository.test_run_finished.) - (repository.test_run_started.) end end |
#find_test_run_finished ⇒ Object
211 212 213 |
# File 'lib/cucumber/query.rb', line 211 def find_test_run_finished repository.test_run_finished end |
#find_test_run_hook_finished_by(test_run_hook_started) ⇒ Object
This method will be called with only 1 message
[TestRunHookStarted]
201 202 203 204 205 |
# File 'lib/cucumber/query.rb', line 201 def find_test_run_hook_finished_by(test_run_hook_started) (test_run_hook_started, i[test_run_hook_started], '#find_test_run_hook_finished_by') repository.test_run_hook_finished_by_test_run_hook_started_id[test_run_hook_started.id] end |
#find_test_run_hook_started_by(test_run_hook_finished) ⇒ Object
This method will be called with only 1 message
[TestRunHookFinished]
193 194 195 196 197 |
# File 'lib/cucumber/query.rb', line 193 def find_test_run_hook_started_by(test_run_hook_finished) (test_run_hook_finished, i[test_run_hook_finished], '#find_test_run_hook_started_by') repository.test_run_hook_started_by_id[test_run_hook_finished.test_run_hook_started_id] end |
#find_test_run_started ⇒ Object
207 208 209 |
# File 'lib/cucumber/query.rb', line 207 def find_test_run_started repository.test_run_started end |
#find_test_step_by(message) ⇒ Object
This method will be called with 1 of these 2 messages
[TestStepStarted || TestStepFinished]
217 218 219 220 221 |
# File 'lib/cucumber/query.rb', line 217 def find_test_step_by() (, i[test_case_started test_case_finished], '#find_test_step_by') repository.test_step_by_id[.test_step_id] end |
#find_test_steps_finished_by(message) ⇒ Object
This method will be called with 1 of these 2 messages
[TestCaseStarted || TestCaseFinished]
234 235 236 237 238 239 240 241 242 243 |
# File 'lib/cucumber/query.rb', line 234 def find_test_steps_finished_by() (, i[test_case_started test_case_finished], '#find_test_steps_finished_by') if .is_a?(Cucumber::Messages::TestCaseStarted) test_steps_finished_by_test_case_started_id.fetch(.id, []) else = find_test_case_started_by() .nil? ? [] : find_test_steps_finished_by() end end |
#find_test_steps_started_by(message) ⇒ Object
This method will be called with 1 of these 2 messages
[TestCaseStarted || TestCaseFinished]
225 226 227 228 229 230 |
# File 'lib/cucumber/query.rb', line 225 def find_test_steps_started_by() (, i[test_case_started test_case_finished], '#find_test_steps_started_by') key = .is_a?(Cucumber::Messages::TestCaseStarted) ? .id : .test_case_started_id repository.test_steps_started_by_test_case_started_id.fetch(key, []) end |