Class: Acouchi::TestRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/acouchi/test_runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ TestRunner

Returns a new instance of TestRunner.



3
4
5
# File 'lib/acouchi/test_runner.rb', line 3

def initialize configuration
  @configuration = configuration
end

Instance Method Details

#startObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/acouchi/test_runner.rb', line 7

def start

  apk_installer = ApkInstaller.new(@configuration)
  apk_installer.uninstall_apk
  apk_installer.install_apk 


  if @configuration.device
    ProcessLauncher.new(Executables.adb,"-s",@configuration.device, "forward", "tcp:#{@configuration.port}", "tcp:7103").start_and_crash_if_process_fails
    @test_runner_process = ProcessLauncher.new(Executables.adb, "-s" ,@configuration.device, "shell", "am", "instrument", "-w", "#{@configuration.target_package}/android.test.InstrumentationTestRunner")
  else
    ProcessLauncher.new(Executables.adb, "forward", "tcp:#{@configuration.port}", "tcp:7103").start_and_crash_if_process_fails
    @test_runner_process = ProcessLauncher.new(Executables.adb, "shell", "am", "instrument", "-w", "#{@configuration.target_package}/android.test.InstrumentationTestRunner")
  end

  @test_runner_process.start_in_background

  sleep 0.1 until ready?
end

#stopObject



27
28
29
# File 'lib/acouchi/test_runner.rb', line 27

def stop
  HTTParty.get("http://127.0.0.1:#{@configuration.port}/finish") rescue nil
end