Class: TestCaseSet
- Inherits:
-
Object
- Object
- TestCaseSet
- Defined in:
- lib/test_case_set.rb
Instance Method Summary collapse
- #case_numbers ⇒ Object
- #condition_count ⇒ Object
- #create_cases ⇒ Object
- #formatted(format) ⇒ Object
- #formatted_input_to_condition_maping(format) ⇒ Object
- #identifier_range ⇒ Object
- #index_of(condition_identifier) ⇒ Object
-
#initialize(condition_identifiers, decision) ⇒ TestCaseSet
constructor
A new instance of TestCaseSet.
- #input_identifiers ⇒ Object
- #input_to_condition_mapping ⇒ Object
- #mcdc_pairs ⇒ Object
- #mcdc_pairs_for(condition_identifier) ⇒ Object
Constructor Details
#initialize(condition_identifiers, decision) ⇒ TestCaseSet
Returns a new instance of TestCaseSet.
4 5 6 7 8 |
# File 'lib/test_case_set.rb', line 4 def initialize(condition_identifiers, decision) @condition_identifiers = condition_identifiers @decision = decision @test_cases = create_cases end |
Instance Method Details
#case_numbers ⇒ Object
16 17 18 |
# File 'lib/test_case_set.rb', line 16 def case_numbers 1..2**condition_count end |
#condition_count ⇒ Object
20 21 22 |
# File 'lib/test_case_set.rb', line 20 def condition_count @condition_identifiers.count end |
#create_cases ⇒ Object
10 11 12 13 14 |
# File 'lib/test_case_set.rb', line 10 def create_cases case_numbers.map do |case_number| TestCase.new(case_number, condition_count, @decision) end end |
#formatted(format) ⇒ Object
60 61 62 63 64 |
# File 'lib/test_case_set.rb', line 60 def formatted(format) @test_cases.inject("") do |output, test_case| output += test_case.formatted(format) end end |
#formatted_input_to_condition_maping(format) ⇒ Object
54 55 56 57 58 |
# File 'lib/test_case_set.rb', line 54 def formatted_input_to_condition_maping(format) input_to_condition_mapping.inject("") do |output, input_condition_pair| output += format % input_condition_pair end end |
#identifier_range ⇒ Object
32 33 34 |
# File 'lib/test_case_set.rb', line 32 def identifier_range 'a'..'z' end |
#index_of(condition_identifier) ⇒ Object
50 51 52 |
# File 'lib/test_case_set.rb', line 50 def index_of(condition_identifier) identifier_range.to_a.index(condition_identifier) end |
#input_identifiers ⇒ Object
28 29 30 |
# File 'lib/test_case_set.rb', line 28 def input_identifiers identifier_range.take(condition_count) end |
#input_to_condition_mapping ⇒ Object
24 25 26 |
# File 'lib/test_case_set.rb', line 24 def input_to_condition_mapping input_identifiers.zip(@condition_identifiers) end |
#mcdc_pairs ⇒ Object
36 37 38 39 40 |
# File 'lib/test_case_set.rb', line 36 def mcdc_pairs input_identifiers.map do |condition_identifier| "#{condition_identifier} => #{mcdc_pairs_for(condition_identifier)}" end end |
#mcdc_pairs_for(condition_identifier) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/test_case_set.rb', line 42 def mcdc_pairs_for(condition_identifier) @test_cases.inject([]) do |mcdc_cases, test_case| mcdc_pair = test_case.mcdc_pair(index_of(condition_identifier)) mcdc_cases << mcdc_pair if test_case.is_mcdc_case_for_index?(index_of(condition_identifier)) mcdc_cases end.uniq end |