Module: Buildr::TestFramework
- Defined in:
- lib/buildr/core/test.rb,
lib/buildr/java/test_result.rb
Overview
The underlying test framework used by TestTask. To add a new test framework, extend TestFramework::Base and add your framework using:
Buildr::TestFramework << MyFramework
Defined Under Namespace
Modules: JRubyBased Classes: Base, Java, JavaBDD, TestResult
Class Method Summary collapse
-
.add(framework) ⇒ Object
(also: <<)
Adds a test framework to the list of supported frameworks.
-
.frameworks ⇒ Object
Returns a list of available test frameworks.
-
.has?(name) ⇒ Boolean
Returns true if the specified test framework exists.
-
.select(name) ⇒ Object
Select a test framework by its name.
-
.select_from(project) ⇒ Object
Identify which test framework applies for this project.
Class Method Details
.add(framework) ⇒ Object Also known as: <<
Adds a test framework to the list of supported frameworks.
For example:
Buildr::TestFramework << Buildr::JUnit
55 56 57 58 |
# File 'lib/buildr/core/test.rb', line 55 def add(framework) @frameworks ||= [] @frameworks |= [framework] end |
.frameworks ⇒ Object
Returns a list of available test frameworks.
62 63 64 |
# File 'lib/buildr/core/test.rb', line 62 def frameworks @frameworks ||= [] end |
.has?(name) ⇒ Boolean
Returns true if the specified test framework exists.
32 33 34 |
# File 'lib/buildr/core/test.rb', line 32 def has?(name) frameworks.any? { |framework| framework.to_sym == name.to_sym } end |
.select(name) ⇒ Object
Select a test framework by its name.
37 38 39 |
# File 'lib/buildr/core/test.rb', line 37 def select(name) frameworks.detect { |framework| framework.to_sym == name.to_sym } end |
.select_from(project) ⇒ Object
Identify which test framework applies for this project.
42 43 44 45 46 47 48 49 |
# File 'lib/buildr/core/test.rb', line 42 def select_from(project) # Look for a suitable test framework based on the compiled language, # which may return multiple candidates, e.g. JUnit and TestNG for Java. # Pick the one used in the parent project, if not, whichever comes first. candidates = frameworks.select { |framework| framework.applies_to?(project) } parent = project.parent parent && candidates.detect { |framework| framework.to_sym == parent.test.framework } || candidates.first end |