class BradyW::JsTest

Executes Javascript tests using Google’s JS Test. By default, the task outputs test results in plain text to stdout.

Attributes

browsers[RW]

Required List of browser paths to run the test on. (surrounded in quotes on Windows)

files[RW]

Required Which Javascript files should be passed on to JS Test driver?

jarpath[RW]

Where is the Test driver JAR located (defaults to “lib/”)

outpath[RW]

Optional If XML output is enabled, what directory should it go to (default is current)

port[RW]

Optional Which port should the Test Driver Server run on (defaults to 9876)

server[RW]

Optional Where should the server be running? Default is localhost, which causes the server to launch when this task is run. If you specify another server here, then this task will NOT launch a server and will instead only run the tests.

version[RW]

Optional Google JS Test Driver in use (defaults to 1.2.1)

xmloutput[RW]

Optional Should XML output be enabled? By default the task looks for the CCNetProject environment variable to decide this

Private Instance Methods

configFile() click to toggle source
   # File lib/jstest.rb
69 def configFile
70         "jsTestDriver.conf"
71 end
exectask() click to toggle source
   # File lib/jstest.rb
37 def exectask
38             genConfigFile
39             cmd = "java -jar #{jarpath}jsTestDriver-#{version}.jar#{portparam}#{browsers} --tests all#{testoutput}"
40     shell cmd do |ok,status|
41        # We want to clean up our temp file in case we fail
42       rm_safe configFile
43       ok or
44       fail "Command failed with status (#{status.exitstatus}):"
45     end             
46 end
genConfigFile() click to toggle source
   # File lib/jstest.rb
48     def genConfigFile
49     # This will include internal Rake FileList exclusion stuff if we don't do this
50     onlyFiles = []
51     @files.each { |f| onlyFiles << f}
52             config = {"server" => "http://#{server}:#{port}",
53                               "load" => onlyFiles}
54             File.open configFile, 'w' do |file|
55                     YAML.dump config, file
56             end
57 end
portparam() click to toggle source
   # File lib/jstest.rb
90 def portparam
91   " --port #{port}" unless @server
92 end
testoutput() click to toggle source
   # File lib/jstest.rb
59 def testoutput
60   if xmloutput
61     " --testOutput " + (@outpath || ".")
62   end
63 end