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_id = nil
  super(output)
end

Instance Method Details

#close(null_notification) ⇒ Object



123
124
125
126
127
# File 'lib/testrail_export.rb', line 123

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

#dump_failures(notification) ⇒ Object



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

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



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

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

#dump_summary(notification) ⇒ Object



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

def dump_summary(notification)
  # Create project if it is not present / could do it setting controlled
  if @project_id.nil?
    puts "TestRail Exporter [INFO] Creating project: #{@options[:project]}"
    @project_id = @client.add_project(@options[:project])['id']
  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) }

  super
end

#start(notification) ⇒ Object

To start



28
29
30
31
32
33
34
35
36
# 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_id = project['id'] if project['name'] == @options[:project] }

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

  super
end