Class: Semilla::FlexUnitTestTask

Inherits:
Rake::Task
  • Object
show all
Defined in:
lib/semilla/test.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(task_name, app) ⇒ FlexUnitTestTask

Returns a new instance of FlexUnitTestTask.



17
18
19
20
21
22
23
24
# File 'lib/semilla/test.rb', line 17

def initialize(task_name, app)
  super task_name, app

  @serverPort = 1024
  @player     = ENV['FLASH_PLAYER']
  @reportpath = "test-report"
  @timeout    = 10 #seconds
end

Instance Attribute Details

#playerObject

Returns the value of attribute player.



14
15
16
# File 'lib/semilla/test.rb', line 14

def player
  @player
end

#reportpathObject

Returns the value of attribute reportpath.



14
15
16
# File 'lib/semilla/test.rb', line 14

def reportpath
  @reportpath
end

#serverPortObject

Returns the value of attribute serverPort.



14
15
16
# File 'lib/semilla/test.rb', line 14

def serverPort
  @serverPort
end

#swfObject

Returns the value of attribute swf.



14
15
16
# File 'lib/semilla/test.rb', line 14

def swf
  @swf
end

#timeoutObject

Returns the value of attribute timeout.



14
15
16
# File 'lib/semilla/test.rb', line 14

def timeout
  @timeout
end

Instance Method Details

#execute(arg = nil) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/semilla/test.rb', line 27

def execute(arg = nil)
  super arg

  ##Check the parameters
  if @serverPort.nil?
    fail "Server port not specified."
  end

  if @swf.nil?
    fail "No swf path specified."
  end

  if @reportpath.nil?
    fail "No report path specified."
  end

  #Writeout the FlashPlayerTrust file
  trust = FlashPlayer::Trust.new
  trust.add File.dirname(@swf)

  puts "[TEST] Start"
  server       = FlexUnitReportServer.new @serverPort
  serverThread = Thread.new {
    #Start the server for getting the flex unit results
    server.start @timeout
  }
  sleep 0.5

  #launch flash
  clientThread = Thread.new {

    begin
      status = Timeout::timeout @timeout do
        flashbin = Semilla::get_player
        #Run the flash player
        puts "Running flash..."
        fr = Semilla::run_player(flashbin, swf)
      end
    rescue Timeout::Error
      fail "Flash player timeout!!!"
    end
  }


  #Wait until finished
  serverThread.join
  clientThread.join

  #parse the reports
  suites    = Semilla::processReports server.results
  #generate junit report
  failcount = Semilla::createReports suites, @reportpath
  puts "[TEST] Done"

  fail "Unit tests failed." if failcount > 0

end