Class: Buildr::MultiTest

Inherits:
TestFramework::Java show all
Defined in:
lib/buildr/java/tests.rb

Overview

A composite test framework that runs multiple other test frameworks.

e.g.,

test.using :multitest, :frameworks => [ Buildr::JUnit, Buildr::TestNG ], :options = {
  :junit => { :fork => true },
  :testng => { ... }
}

Instance Attribute Summary collapse

Attributes inherited from TestFramework::Base

#options, #task

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TestFramework::Java

dependencies

Methods inherited from TestFramework::Base

dependencies, to_sym

Constructor Details

#initialize(task, options) ⇒ MultiTest

:nodoc:



367
368
369
370
371
372
373
374
# File 'lib/buildr/java/tests.rb', line 367

def initialize(task, options) #:nodoc:
  super
  fail 'Missing :frameworks option' unless options[:frameworks]
  @frameworks = options[:frameworks].map do |f|
    framework_options = (options[:options] || {})[f.to_sym] || {}
    f.new(task, framework_options)
  end
end

Instance Attribute Details

#frameworksObject

Returns the value of attribute frameworks.



365
366
367
# File 'lib/buildr/java/tests.rb', line 365

def frameworks
  @frameworks
end

Class Method Details

.applies_to?(project) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


360
361
362
# File 'lib/buildr/java/tests.rb', line 360

def applies_to?(project)  #:nodoc:
  false # no auto-detection, should be set explicitly
end

Instance Method Details

#dependenciesObject

:nodoc:



376
377
378
379
380
381
382
# File 'lib/buildr/java/tests.rb', line 376

def dependencies #:nodoc:
  unless @dependencies
    @dependencies = TestFramework::Java.dependencies
    @dependencies += @frameworks.map { |f| f.dependencies }.flatten
  end
  @dependencies
end

#run(tests, dependencies) ⇒ Object

:nodoc:



389
390
391
392
393
394
395
396
397
398
399
400
401
402
# File 'lib/buildr/java/tests.rb', line 389

def run(tests, dependencies)  #:nodoc:
  framework_for_test = @frameworks.inject({}) do |hash, f|
    f.tests(dependencies).each { |t| hash[t] = f }
    hash
  end

  tests_by_framework = tests.group_by { |t| framework_for_test[t] }

  passed = []
  tests_by_framework.each do |f, tests|
    passed += f.run(tests, dependencies)
  end
  passed
end

#tests(dependencies) ⇒ Object



385
386
387
# File 'lib/buildr/java/tests.rb', line 385

def tests(dependencies)
  @frameworks.map { |f| f.tests(dependencies) }.flatten
end