Class: TestRunner
- Inherits:
-
Object
- Object
- TestRunner
- Defined in:
- lib/java_autotest/test_runner.rb
Constant Summary collapse
- ICON =
File.(File.join(File.dirname(__FILE__), '..', '..', 'img', 'java_icon.png'))
- Title =
'Java AutoTest'
Instance Attribute Summary collapse
-
#build_tool ⇒ Object
Returns the value of attribute build_tool.
Class Method Summary collapse
Instance Method Summary collapse
- #discover_build_tool ⇒ Object
-
#initialize ⇒ TestRunner
constructor
A new instance of TestRunner.
- #notify(message) ⇒ Object
- #run_all_tests ⇒ Object
- #run_test(test_class) ⇒ Object
Constructor Details
#initialize ⇒ TestRunner
Returns a new instance of TestRunner.
10 11 12 |
# File 'lib/java_autotest/test_runner.rb', line 10 def initialize @build_tool = discover_build_tool end |
Instance Attribute Details
#build_tool ⇒ Object
Returns the value of attribute build_tool.
2 3 4 |
# File 'lib/java_autotest/test_runner.rb', line 2 def build_tool @build_tool end |
Class Method Details
.valid_tools ⇒ Object
6 7 8 |
# File 'lib/java_autotest/test_runner.rb', line 6 def self.valid_tools %w(mvn gradle) end |
Instance Method Details
#discover_build_tool ⇒ Object
14 15 16 |
# File 'lib/java_autotest/test_runner.rb', line 14 def discover_build_tool File.exists?("build.gradle") ? "gradle" : "mvn" end |
#notify(message) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/java_autotest/test_runner.rb', line 31 def notify() case RUBY_PLATFORM when /darwin/ system "growlnotify -t '#{Title}' -m '#{}' --image #{ICON}" when /linux/ system "notify-send '#{Title}' '#{}' --icon #{ICON}" end end |
#run_all_tests ⇒ Object
25 26 27 28 29 |
# File 'lib/java_autotest/test_runner.rb', line 25 def run_all_tests green = system("#{@build_tool} test") notify "Build Success" if green notify "Build Broken" unless green end |
#run_test(test_class) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/java_autotest/test_runner.rb', line 18 def run_test(test_class) command = ".single" if @build_tool == "gradle" green = system("#{@build_tool} -Dtest#{command}=#{test_class} test") notify "Test Failure: #{test_class}" unless green green end |