Module: UE4TestRunner

Defined in:
lib/runner.rb

Constant Summary collapse

UE4_ROOT =
"D:\\UE_4.26"
EXECUTABLE_LOCATION =
"\\Engine\\Binaries\\Win64\\UE4Editor-Cmd.exe"
FLAGS =
'-unattended -silent -nopause -NullRHI -testexit="Automation Test Queue Empty" -log -log=RunTests.log'
MISSING_FILE_ERROR_MESSAGE =
"File does not exists D:"
TEST_RESULT_DIR =
'TestResult'

Instance Method Summary collapse

Instance Method Details

#build_commandObject



28
29
30
# File 'lib/runner.rb', line 28

def build_command
  "#{UE4_ROOT}#{EXECUTABLE_LOCATION} #{project_file_path} #{FLAGS} #{tests_command} #{report_outputh_path}"
end

#current_directoryObject



50
51
52
# File 'lib/runner.rb', line 50

def current_directory
  File.expand_path(File.dirname(__FILE__))
end

#project_file_pathObject



32
33
34
35
36
# File 'lib/runner.rb', line 32

def project_file_path
  file = Dir.entries(".").select {|file_name| file_name.include?('.uproject')}.first
  raise MISSING_FILE_ERROR_MESSAGE if file.nil?
  File.expand_path(file, File.dirname(file))
end

#report_outputh_pathObject



46
47
48
# File 'lib/runner.rb', line 46

def report_outputh_path
  "-ReportOutputPath=\"#{current_directory}\\#{TEST_RESULT_DIR}\""
end

#runObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/runner.rb', line 11

def run
  begin
      puts "Running tests..."
      system(build_command, :out => File::NULL)
      file_name = "#{current_directory}\\#{TEST_RESULT_DIR}\\index.json"

      puts "#{file_name}: #{MISSING_FILE_ERROR_MESSAGE}" and return unless File.file?(file_name)

      tests = Parser::parse(file_name)
      tests.each {|test| puts test.pretty}

      FileUtils.rm_rf("#{current_directory}#{TEST_RESULT_DIR}")
  rescue RuntimeError
      puts MISSING_FILE_ERROR_MESSAGE
  end
end

#tests_commandObject



38
39
40
# File 'lib/runner.rb', line 38

def tests_command
  "-ExecCmds=\"Automation RunTests #{tests_to_run}\""
end

#tests_to_runObject



42
43
44
# File 'lib/runner.rb', line 42

def tests_to_run
  ARGV[0]
end