Class: Allure::FileWriter

Inherits:
Object
  • Object
show all
Defined in:
allure-ruby-commons/lib/allure_ruby_commons/file_writer.rb

Overview

Allure result file writer

Constant Summary collapse

TEST_RESULT_SUFFIX =

Returns test result suffix.

Returns:

  • (String)

    test result suffix

"-result.json"
TEST_RESULT_CONTAINER_SUFFIX =

Returns test result container suffix.

Returns:

  • (String)

    test result container suffix

"-container.json"
ATTACHMENT_FILE_SUFFIX =

Returns attachment file suffix.

Returns:

  • (String)

    attachment file suffix

"-attachment"

Instance Method Summary collapse

Instance Method Details

#write_attachment(source, attachment) ⇒ void

This method returns an undefined value.

Write allure attachment file

Parameters:

  • source (File, String)

    File or string of attachment to save

  • attachment (Allure::Attachment)

31
32
33
# File 'allure-ruby-commons/lib/allure_ruby_commons/file_writer.rb', line 31

def write_attachment(source, attachment)
  source.is_a?(File) ? copy(source.path, attachment.source) : write(attachment.source, source)
end

#write_environment(environment) ⇒ void

This method returns an undefined value.

Write allure report environment info

Parameters:

  • environment (Hash<Symbol, String>)

38
39
40
41
42
# File 'allure-ruby-commons/lib/allure_ruby_commons/file_writer.rb', line 38

def write_environment(environment)
  environment.reduce("") { |e, (k, v)| e + "#{k}=#{v}\n" }.tap do |env|
    write("environment.properties", env)
  end
end

#write_test_result(test_result) ⇒ void

This method returns an undefined value.

Write test result

Parameters:


16
17
18
# File 'allure-ruby-commons/lib/allure_ruby_commons/file_writer.rb', line 16

def write_test_result(test_result)
  write("#{test_result.uuid}#{TEST_RESULT_SUFFIX}", test_result.to_json)
end

#write_test_result_container(test_container_result) ⇒ void

This method returns an undefined value.

Write test result container

Parameters:


23
24
25
# File 'allure-ruby-commons/lib/allure_ruby_commons/file_writer.rb', line 23

def write_test_result_container(test_container_result)
  write("#{test_container_result.uuid}#{TEST_RESULT_CONTAINER_SUFFIX}", test_container_result.to_json)
end