Class: Datacraft::Tools::QA::AllureTestCases

Inherits:
Object
  • Object
show all
Defined in:
lib/datacraft/tools/qa/allure_test_cases.rb

Overview

Allure Test Case Reader

Instance Method Summary collapse

Constructor Details

#initialize(path, pattern: '*-testsuite.xml', with_test_suite_info: true) ⇒ AllureTestCases

Returns a new instance of AllureTestCases.



6
7
8
9
10
# File 'lib/datacraft/tools/qa/allure_test_cases.rb', line 6

def initialize(path, pattern: '*-testsuite.xml', with_test_suite_info: true)
  @path = path
  @with_test_suite_info = with_test_suite_info
  @test_suite_files = Pathname.glob("#{path}/#{pattern}")
end

Instance Method Details

#eachObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/datacraft/tools/qa/allure_test_cases.rb', line 12

def each
  @test_suite_files.each do |file|
    hash = to_hash file
    next unless valid? hash
    test_suite = hash['test_suite']
    test_suite['path'] = file.to_s
    test_cases = get_test_cases test_suite
    test_cases = [test_cases] if test_cases.is_a? Hash
    test_cases.each do |test_case|
      test_case['test_suite'] = test_suite if @with_test_suite_info
      yield test_case
    end
  end
end