Class: Gitlab::QA::Report::ResultsInTestCases

Inherits:
ReportAsIssue show all
Includes:
ResultsReporterShared
Defined in:
lib/gitlab/qa/report/results_in_testcases.rb

Overview

Uses the API to create or update GitLab test cases with the results of tests from RSpec report files.

Constant Summary

Constants included from ResultsReporterShared

Gitlab::QA::Report::ResultsReporterShared::TEST_CASE_RESULTS_SECTION_TEMPLATE

Constants inherited from ReportAsIssue

Gitlab::QA::Report::ReportAsIssue::MAX_TITLE_LENGTH

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ResultsReporterShared

#find_issue, #find_issue_by_iid, #new_issue_labels, #search_term, #up_to_date_labels, #update_issue_title

Methods inherited from ReportAsIssue

#invoke!

Constructor Details

#initialize(**kwargs) ⇒ ResultsInTestCases

Returns a new instance of ResultsInTestCases.



14
15
16
17
# File 'lib/gitlab/qa/report/results_in_testcases.rb', line 14

def initialize(**kwargs)
  super
  @issue_type = 'test_case'
end

Instance Attribute Details

#gitlabObject (readonly)

Returns the value of attribute gitlab.



10
11
12
# File 'lib/gitlab/qa/report/results_in_testcases.rb', line 10

def gitlab
  @gitlab
end

#issue_typeObject (readonly)

Returns the value of attribute issue_type.



10
11
12
# File 'lib/gitlab/qa/report/results_in_testcases.rb', line 10

def issue_type
  @issue_type
end

Instance Method Details



23
24
25
26
27
28
29
# File 'lib/gitlab/qa/report/results_in_testcases.rb', line 23

def add_issue_link_to_testcase(testcase, issue, test)
  results_section = testcase.description.include?(TEST_CASE_RESULTS_SECTION_TEMPLATE) ? '' : TEST_CASE_RESULTS_SECTION_TEMPLATE

  gitlab.edit_issue(iid: testcase.iid, options: { description: (testcase.description + results_section + "\n\n#{issue.web_url}") })
  # We are using test.testcase for the url here instead of testcase.web_url since it has the updated test case path
  puts "Added results issue #{issue.web_url} link to test case #{test.testcase}"
end

#find_or_create_testcase(test) ⇒ Object



19
20
21
# File 'lib/gitlab/qa/report/results_in_testcases.rb', line 19

def find_or_create_testcase(test)
  find_testcase(test) || create_issue(test)
end

#update_testcase(testcase, test) ⇒ Object



31
32
33
34
# File 'lib/gitlab/qa/report/results_in_testcases.rb', line 31

def update_testcase(testcase, test)
  puts "Test case labels updated." if update_labels(testcase, test)
  puts "Test case quarantine section updated." if update_quarantine_link(testcase, test)
end