Class: TestBoosters::Cucumber::Thread

Inherits:
Object
  • Object
show all
Defined in:
lib/test_boosters/cucumber/thread.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(files_from_split_configuration, leftover_files) ⇒ Thread

Returns a new instance of Thread.



8
9
10
11
# File 'lib/test_boosters/cucumber/thread.rb', line 8

def initialize(files_from_split_configuration, leftover_files)
  @files_from_split_configuration = files_from_split_configuration
  @leftover_files = leftover_files
end

Instance Attribute Details

#files_from_split_configurationObject (readonly)

Returns the value of attribute files_from_split_configuration.



5
6
7
# File 'lib/test_boosters/cucumber/thread.rb', line 5

def files_from_split_configuration
  @files_from_split_configuration
end

#leftover_filesObject (readonly)

Returns the value of attribute leftover_files.



6
7
8
# File 'lib/test_boosters/cucumber/thread.rb', line 6

def leftover_files
  @leftover_files
end

Instance Method Details

#all_filesObject



57
58
59
# File 'lib/test_boosters/cucumber/thread.rb', line 57

def all_files
  @all_files ||= files_from_split_configuration + leftover_files
end

#cucumber_commandObject



61
62
63
# File 'lib/test_boosters/cucumber/thread.rb', line 61

def cucumber_command
  "bundle exec cucumber #{all_files.join(" ")}"
end

#display_thread_infoObject



32
33
34
35
36
37
38
39
40
# File 'lib/test_boosters/cucumber/thread.rb', line 32

def display_thread_info
  TestBoosters::Shell.display_files(
    "Known specs for this thread",
    files_from_split_configuration)

  TestBoosters::Shell.display_files(
    "Leftover specs for this thread",
    leftover_files)
end

#report_pathObject



65
66
67
# File 'lib/test_boosters/cucumber/thread.rb', line 65

def report_path
  @report_path ||= ENV["REPORT_PATH"] || "#{ENV["HOME"]}/cucumber_report.json"
end

#runObject

:reek:TooManyStatements { max_statements: 10 }



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/test_boosters/cucumber/thread.rb', line 14

def run
  if all_files.empty?
    puts("No files to run in this thread!")

    return 0
  end

  run_cucumber_config

  display_thread_info

  exit_status = run_cucumber

  upload_report

  exit_status
end

#run_cucumberObject



48
49
50
51
# File 'lib/test_boosters/cucumber/thread.rb', line 48

def run_cucumber
  TestBoosters::Shell.display_title("Running Cucumber")
  TestBoosters::Shell.execute(cucumber_command)
end

#run_cucumber_configObject



42
43
44
45
46
# File 'lib/test_boosters/cucumber/thread.rb', line 42

def run_cucumber_config
  CucumberBoosterConfig::Injection.new(Dir.pwd, report_path).run
  puts "-------------------------------------------------------"
  puts
end

#upload_reportObject



53
54
55
# File 'lib/test_boosters/cucumber/thread.rb', line 53

def upload_report
  TestBoosters::InsightsUploader.upload("cucumber", report_path)
end