-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add update test formatter and update tasks
- Loading branch information
Showing
10 changed files
with
100 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
require 'rspec/core/formatters/base_formatter' | ||
module TMJFormatter | ||
class BaseFormatter < RSpec::Core::Formatters::BaseFormatter | ||
DEFAULT_OPTIONS = { update_existing_tests: false, test_owner: nil, custom_labels: nil}.freeze | ||
|
||
NOTIFICATIONS = %i[start, example_started].freeze | ||
|
||
def start(_notification) | ||
@options = DEFAULT_OPTIONS.merge(TMJFormatter.config.create_test_formatter_options) | ||
@client = TMJ::Client.new(TMJFormatter.config.to_hash) | ||
end | ||
|
||
private | ||
|
||
def process_example(example) | ||
{ | ||
"projectKey": configure_project_key, | ||
"name": example.metadata[:full_description], | ||
"objective": example.metadata[:objective], | ||
"precondition": example.metadata[:precondition], | ||
"folder": example.metadata[:folder], | ||
"status": example.metadata[:status], | ||
"priority": example.metadata[:priority], | ||
"owner": @options[:test_owner], | ||
"labels": @options[:custom_labels], | ||
"testScript": process_steps(example.metadata[:steps]) | ||
}.delete_if { |k, v| v.nil? || v.empty?} | ||
end | ||
|
||
|
||
def configure_project_key | ||
self.class.to_s == 'TMJUpdateTestFormatter' ? nil : TMJFormatter.config.project_id | ||
end | ||
|
||
def process_steps(example) | ||
return unless example | ||
arr = [] | ||
example.each { |s| arr << {"description": s[:step_name]} } | ||
{ | ||
"type": "STEP_BY_STEP", | ||
"steps": arr | ||
} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module TMJFormatter | ||
VERSION = '0.1.11'.freeze | ||
VERSION = '0.1.18'.freeze | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require_relative 'tmj_formatter/helpers/base_formatter' | ||
|
||
class TMJUpdateTestFormatter < TMJFormatter::BaseFormatter | ||
RSpec::Core::Formatters.register self, *NOTIFICATIONS | ||
|
||
def example_started(notification) | ||
if (notification.example.metadata.has_key?(:test_id) && notification.example.metadata[:test_id].strip.empty?) || !notification.example.metadata.has_key?(:test_id) | ||
return | ||
end | ||
|
||
response = @client.TestCase.update(notification.example.metadata[:test_id], process_example(notification.example)) | ||
if response.code != 200 | ||
puts TMJ::TestCaseError.new(response).message | ||
exit | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
require "spec_helper" | ||
|
||
PRECONDITION = 'PROVIDE SOME DATA HERE' | ||
|
||
RSpec.describe 'Test Case' do | ||
it 'Test Example From Local', precondition: PRECONDITION, test_id: 'CC-T1444' do |e| | ||
e.step 'test' do | ||
OBJECTIVE = 'JUST A TEST' | ||
RSpec.describe 'Test Case:', folder: '/Test' do | ||
it 'Test Example From Local', objective: OBJECTIVE, precondition: PRECONDITION, test_id: 'CC-T1613' do |e| | ||
e.step 'test 1' do | ||
end | ||
|
||
e.step 'test 2' do | ||
end | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe 'Tasks with steps', skip: true do | ||
it 'TODO' do |e| | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe 'Tasks without steps', skip: true do | ||
it 'TODO' do |e| | ||
end | ||
end |