Class: TestCommand
- Defined in:
- lib/spiderfw/cmd/commands/test.rb
Instance Method Summary collapse
-
#initialize ⇒ TestCommand
constructor
A new instance of TestCommand.
Constructor Details
#initialize ⇒ TestCommand
Returns a new instance of TestCommand.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 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 |
# File 'lib/spiderfw/cmd/commands/test.rb', line 4 def initialize super( 'test', true, true ) @short_desc = _("Manage tests") # @description = _("") @apps = [] run_cmd = CmdParse::Command.new( 'run', false ) run_cmd.short_desc = _("Run tests") # run.options = CmdParse::OptionParserWrapper.new do |opt| # opt.on("--app", # _("Run tests only for an app"), # "-a"){ |app| # @apps << app # } # end run_cmd.set_execution_block do |apps| require 'test/unit/collector/dir' require 'test/unit' apps = Spider.apps.keys if (!apps || apps.length < 1) collector = Test::Unit::Collector::Dir.new() apps.each do |name| next unless File.exist?(Spider.apps[name].test_path) collector.collect(Spider.apps[name].test_path) end end self.add_command(run_cmd) self_cmd = CmdParse::Command.new('self', false) self_cmd.short_desc = _("Run framework tests") self_cmd.set_execution_block do require 'test/unit/collector/dir' require 'test/unit' $SPIDER_RUNMODE = 'test' require 'spiderfw' test_env = "#{$SPIDER_PATH}/test" # Dir.cwd(test_env) $:.push(test_env) apps = Spider.find_apps_in_folder("#{test_env}/apps") Spider.apps.clear apps.each{ |app| Spider.load_app_at_path app } Spider._test_setup collector = Test::Unit::Collector::Dir.new() collector.collect("#{test_env}/tests") Spider._test_teardown end self.add_command(self_cmd) end |