Class: TestrailExport

Inherits:
RSpec::Core::Formatters::BaseTextFormatter
  • Object
show all
Defined in:
lib/testrail_export.rb

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ TestrailExport

TODO: after exporter is done and working remove unnecessary overriden methods



21
22
23
24
25
# File 'lib/testrail_export.rb', line 21

def initialize(output)
  @options = {}
  @project = nil
  super(output)
end

Instance Method Details

#close(null_notification) ⇒ Object



125
126
127
128
129
# File 'lib/testrail_export.rb', line 125

def close(null_notification)
  # TODO: could close any open connection
  puts "TestRail Exporter [INFO] Closing..."
  super
end

#dump_failures(notification) ⇒ Object



98
99
100
101
# File 'lib/testrail_export.rb', line 98

def dump_failures(notification)
  # puts "dump fail notification: #{notification.inspect}"
  # super
end

#dump_pending(notification) ⇒ Object

def start_dump(null_notification)

puts "start_dump notification: #{null_notification.inspect}"

end



93
94
95
96
# File 'lib/testrail_export.rb', line 93

def dump_pending(notification)
  # puts "dump pend notification: #{notification.inspect}"
  # super
end

#dump_summary(notification) ⇒ Object



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/testrail_export.rb', line 103

def dump_summary(notification)
  @client.get_projects.each { |project| @project = project if project['name'] == @options[:project] } unless @project
  # Create project if it is not present / could do it setting controlled
  if @project.nil?
    puts "TestRail Exporter [INFO] Creating project: #{@options[:project]}"
    @project = @client.add_project(@options[:project])
  end

  suites = Hash.new do |h,k|
    h[k] = Tree::TreeNode.new(k, @client.find_or_create_suite(k, @project['id']) )
  end


  notification.examples.each do |example|
    build_hierarchy_tree!(suites, example)
  end

  suites.each { |_, suite| update_test_run(suite, @run_name) }

  super
end

#start(notification) ⇒ Object

To start



28
29
30
31
32
33
34
35
36
37
# File 'lib/testrail_export.rb', line 28

def start(notification)
  @options = RSpec.configuration.testrail_formatter_options
  @client = Testrail::Client.new(@options)
  @client.get_projects.each { |project| @project = project if project['name'] == @options[:project] }
  @run_name = ENV['TEST_RUN_NAME'] || start_timestamp

  puts "TestRail Exporter [INFO] Executing #{notification.count} tests. Loaded in #{notification.load_time}"

  super
end