Welcome to mirror list, hosted at ThFree Co, Russian Federation.

allure_metadata_formatter.rb « support « qa « qa - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8a18eeca839953914201325a33bc6a4d92019463 (plain)
1
2
3
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
30
31
32
33
34
35
36
37
# frozen_string_literal: true

require 'rspec/core'
require "rspec/core/formatters/base_formatter"

module QA
  module Support
    class AllureMetadataFormatter < ::RSpec::Core::Formatters::BaseFormatter
      ::RSpec::Core::Formatters.register(
        self,
        :example_started
      )

      # Starts example
      # @param [RSpec::Core::Notifications::ExampleNotification] example_notification
      # @return [void]
      def example_started(example_notification)
        example = example_notification.example

        testcase = example.metadata[:testcase]
        example.tms('Testcase', testcase) if testcase

        quarantine_issue = example.metadata.dig(:quarantine, :issue)
        example.issue('Quarantine issue', quarantine_issue) if quarantine_issue

        spec_file = example.file_path.split('/').last
        example.issue(
          'Failure issues',
          "https://gitlab.com/gitlab-org/gitlab/-/issues?scope=all&state=opened&search=#{spec_file}"
        )
        return unless Runtime::Env.running_in_ci?

        example.add_link(name: "Job(#{Runtime::Env.ci_job_name})", url: Runtime::Env.ci_job_url)
      end
    end
  end
end