Sha256: ab40b164bdc646cc29505e6bb38fd2adea28227dc42a494788827f868386fd3c

Contents?: true

Size: 1.06 KB

Versions: 8

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

module GitlabQuality
  module TestTooling
    module TestResult
      class JUnitTestResult < BaseTestResult
        attr_accessor :testcase # Ignore it for now

        def name
          report['name']
        end

        def file
          report['file'].delete_prefix('./')
        end

        def skipped?
          report.search('skipped').any?
        end

        def failures # rubocop:disable Metrics/AbcSize
          failures = report.search('failure')
          return [] if failures.empty?

          failures.map do |exception|
            trace = exception.content.split("\n").map(&:strip)
            spec_file_first_index = trace.rindex do |line|
              line.include?(File.basename(report['file']))
            end

            exception['message'].gsub!(/(private_token=)[\w-]+/, '********')

            {
              'message' => "#{exception['type']}: #{exception['message']}",
              'stacktrace' => trace.slice(0..spec_file_first_index).join("\n")
            }
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
gitlab_quality-test_tooling-1.3.0 lib/gitlab_quality/test_tooling/test_result/j_unit_test_result.rb
gitlab_quality-test_tooling-1.2.0 lib/gitlab_quality/test_tooling/test_result/j_unit_test_result.rb
gitlab_quality-test_tooling-1.1.0 lib/gitlab_quality/test_tooling/test_result/j_unit_test_result.rb
gitlab_quality-test_tooling-1.0.0 lib/gitlab_quality/test_tooling/test_result/j_unit_test_result.rb
gitlab_quality-test_tooling-0.9.3 lib/gitlab_quality/test_tooling/test_result/j_unit_test_result.rb
gitlab_quality-test_tooling-0.9.2 lib/gitlab_quality/test_tooling/test_result/j_unit_test_result.rb
gitlab_quality-test_tooling-0.9.1 lib/gitlab_quality/test_tooling/test_result/j_unit_test_result.rb
gitlab_quality-test_tooling-0.9.0 lib/gitlab_quality/test_tooling/test_result/j_unit_test_result.rb