Class: Buildr::TestFramework::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/buildr/core/test.rb

Overview

Base class for all test frameworks, with common functionality. Extend and over-ride as you see fit (see JUnit as an example).

Direct Known Subclasses

Java

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(test_task, options) ⇒ Base

Construct a new test framework with the specified options. Note that options may change before the framework is run.



95
96
97
98
# File 'lib/buildr/core/test.rb', line 95

def initialize(test_task, options)
  @options = options
  @task = test_task
end

Instance Attribute Details

#optionsObject (readonly)

Options for this test framework.



101
102
103
# File 'lib/buildr/core/test.rb', line 101

def options
  @options
end

#taskObject (readonly)

The test task we belong to



103
104
105
# File 'lib/buildr/core/test.rb', line 103

def task
  @task
end

Class Method Details

.applies_to?(project) ⇒ Boolean

Returns true if this framework applies to the current project. For example, JUnit returns true if the tests are written in Java.

Returns:

  • (Boolean)


81
82
83
# File 'lib/buildr/core/test.rb', line 81

def applies_to?(project)
  raise 'Not implemented'
end

.dependenciesObject

Returns a list of dependencies for this framework. Default is an empty list, override to add dependencies.



87
88
89
# File 'lib/buildr/core/test.rb', line 87

def dependencies
  @dependencies ||= []
end

.to_symObject

The framework’s identifier (e.g. :junit). Inferred from the class name.



75
76
77
# File 'lib/buildr/core/test.rb', line 75

def to_sym
  @symbol ||= name.split('::').last.downcase.to_sym
end

Instance Method Details

#dependenciesObject

Returns a list of dependenices for this framework. Defaults to calling the #dependencies method on the class.



107
108
109
# File 'lib/buildr/core/test.rb', line 107

def dependencies
  self.class.dependencies
end

#run(tests, dependencies) ⇒ Object

TestTask calls this method to run the named (and only those) tests. This method returns the list of tests that ran successfully.



124
125
126
# File 'lib/buildr/core/test.rb', line 124

def run(tests, dependencies)
  raise 'Not implemented'
end

#tests(dependencies) ⇒ Object

TestTask calls this method to return a list of test names that can be run in this project. It then applies the include/exclude patterns to arrive at the list of tests that will be run, and call the #run method with that list.

This method should return a list suitable for using with the #run method, but also suitable for the user to manage. For example, JUnit locates all the tests in the test.compile.target directory, and returns the class names, which are easier to work with than file names.



118
119
120
# File 'lib/buildr/core/test.rb', line 118

def tests(dependencies)
  raise 'Not implemented'
end