Module: Taf::CreateDirectories

Defined in:
lib/taf/create_directories.rb

Overview

create_directories.rb - Creates folder structures.

Class Method Summary collapse

Class Method Details

.construct_projectdirsObject

create the project directories and open the test results file, the screenshot will be placed in a unique filename based upon the testStep.

A single top-level directory named after the Project ID will be used. The target sub-directories will be created for each run of the test. —-> Project directory (working directory)

——-> directory named after the test run ID UUID



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/taf/create_directories.rb', line 22

def self.construct_projectdirs
  # create top-level directory if it doesn't already exist:
  # Results/Project_id
  project_id = Taf::JSONParser.project_id.delete(' ')
  project_dir = File.join('Results', project_id)

  FileUtils.mkdir_p(project_dir)

  # Generate UUID
  @run_uuid = SecureRandom.uuid
end

.construct_testspecdirsObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/taf/create_directories.rb', line 34

def self.construct_testspecdirs
  # create directories for each test spec for screenshots:
  # Results/Project_id/Run_ID_UUID
  project_id = Taf::JSONParser.project_id.delete(' ')
  screenshot_dir = File.join('Results', project_id, "Run_ID_#{@run_uuid}")

  abs_path_screenshot_dir = File.absolute_path(screenshot_dir)
  FileUtils.mkdir_p(abs_path_screenshot_dir)
  # if any issues then set error message and re-raise the exception
rescue StandardError => e
  # construct the error message from custom text and the actual system error
  # message (converted to a string)
  error_to_display = 'Error creating directory:' + e.to_s
  raise error_to_display
else
  # if no exception then return the screenshot file directory path
  abs_path_screenshot_dir
end