Class: Fastlane::Actions::TestsFromJunitAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/test_center/actions/tests_from_junit.rb

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



75
76
77
# File 'lib/fastlane/plugin/test_center/actions/tests_from_junit.rb', line 75

def self.authors
  ["lyndsey-ferguson/lyndseydf"]
end

.available_optionsObject



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/fastlane/plugin/test_center/actions/tests_from_junit.rb', line 40

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :junit,
      env_name: "FL_SUPPRESS_TESTS_FROM_JUNIT_JUNIT_REPORT", # The name of the environment variable
      description: "The junit xml report file from which to collect the tests to suppress",
      verify_block: proc do |path|
        UI.user_error!("Error: cannot find the junit xml report file '#{path}'") unless File.exist?(path)
      end
    )
  ]
end

.categoryObject



79
80
81
# File 'lib/fastlane/plugin/test_center/actions/tests_from_junit.rb', line 79

def self.category
  :testing
end

.descriptionObject

:nocov:



36
37
38
# File 'lib/fastlane/plugin/test_center/actions/tests_from_junit.rb', line 36

def self.description
  "☑️ Retrieves the failing and passing tests as reported in a junit xml file"
end

.example_codeObject



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/fastlane/plugin/test_center/actions/tests_from_junit.rb', line 61

def self.example_code
  [
    "
    UI.important(
      'example: ' \\
      'get the failed and passing tests from the junit test report file'
    )
    result = tests_from_junit(junit: './spec/fixtures/junit.xml')
    UI.message(\"Passing tests: \#{result[:passing]}\")
    UI.message(\"Failed tests: \#{result[:failed]}\")
    "
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/fastlane/plugin/test_center/actions/tests_from_junit.rb', line 83

def self.is_supported?(platform)
  %i[ios mac].include?(platform)
end

.return_valueObject



53
54
55
56
57
58
59
# File 'lib/fastlane/plugin/test_center/actions/tests_from_junit.rb', line 53

def self.return_value
  "A Hash with information about the test results:\r\n" \
  "failed: an Array of the failed test identifiers\r\n" \
  "passing: an Array of the passing test identifiers\r\n" \
  "failure_details: a Hash with failed test identifiers as the key, and " \
  "a Hash with :message and :location details for the failed test"
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fastlane/plugin/test_center/actions/tests_from_junit.rb', line 4

def self.run(params)
  report = ::TestCenter::Helper::XcodeJunit::Report.new(params[:junit])
  passing = []
  failed = []
  failure_details = {}
  report.testables.each do |testable|
    testable.testsuites.each do |testsuite|
      testsuite.testcases.each do |testcase|
        if testcase.passed?
          passing << testcase.identifier
        else
          failed << testcase.identifier
          failure_details[testcase.identifier] = {
            message: testcase.message,
            location: testcase.location
          }
        end
      end
    end
  end
  {
    failed: failed,
    passing: passing,
    failure_details: failure_details
  }
end