Sha256: 1e15061b9d7d327acb971c12299d2255447fdbe24f94a2f817beba16fd859568

Contents?: true

Size: 973 Bytes

Versions: 1

Compression:

Stored size: 973 Bytes

Contents

class TestRunner
  attr_accessor :build_tool
  ICON = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'img', 'java_icon.png'))
  Title = 'Java AutoTest'  

  def self.valid_tools
    %w(mvn gradle)
  end

  def initialize
    @build_tool = discover_build_tool
  end

  def discover_build_tool
    File.exists?("build.gradle") ? "gradle" : "mvn" 
  end

  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

  def run_all_tests
    green = system("#{@build_tool} test")
    notify "Build Success" if green
    notify "Build Broken" unless green 
  end

  def notify(message)
    case RUBY_PLATFORM
    when /darwin/
      system "growlnotify -t '#{Title}' -m '#{message}' --image #{ICON}"
    when /linux/
      system "notify-send '#{Title}' '#{message}' --icon #{ICON}"
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
java-autotest-0.0.2 lib/java_autotest/test_runner.rb