Class: Micron::Runner::TestFile
- Inherits:
-
Object
- Object
- Micron::Runner::TestFile
- Defined in:
- lib/micron/runner/test_file.rb
Instance Method Summary collapse
-
#collect_coverage ⇒ Object
Simply load the file and collect coverage.
-
#initialize(filename) ⇒ TestFile
constructor
A new instance of TestFile.
-
#load(coverage = false) ⇒ Object
Load the test file.
-
#run(run_clazz) ⇒ Array<Object>
Execute the tests in the file, using the given Clazz.
-
#run_method(test_clazz, test_method, run_clazz) ⇒ Method
Run the given test method.
Constructor Details
#initialize(filename) ⇒ TestFile
Returns a new instance of TestFile.
6 7 8 |
# File 'lib/micron/runner/test_file.rb', line 6 def initialize(filename) @filename = filename end |
Instance Method Details
#collect_coverage ⇒ Object
Simply load the file and collect coverage
24 25 26 27 28 29 30 31 |
# File 'lib/micron/runner/test_file.rb', line 24 def collect_coverage worker = ForkWorker.new do load(true) EasyCov.dump end worker.run worker.wait end |
#load(coverage = false) ⇒ Object
Load the test file
13 14 15 16 17 18 19 20 21 |
# File 'lib/micron/runner/test_file.rb', line 13 def load(coverage=false) if coverage then file = @filename EasyCov.filters << lambda { |f| f == file } EasyCov.start end require @filename return nil end |
#run(run_clazz) ⇒ Array<Object>
Execute the tests in the file, using the given Clazz
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/micron/runner/test_file.rb', line 38 def run(run_clazz) results = [] test_clazz = TestCase.subclasses.last begin clazz = run_clazz.new(test_clazz, @filename) Micron.runner.report(:start_class, clazz) if !clazz.methods.empty? then clazz.run results << clazz end Micron.runner.report(:end_class, clazz) rescue Exception => ex # Error with loading the test class itself results << ex return results end return results end |
#run_method(test_clazz, test_method, run_clazz) ⇒ Method
Run the given test method
69 70 71 72 73 74 75 |
# File 'lib/micron/runner/test_file.rb', line 69 def run_method(test_clazz, test_method, run_clazz) clazz = run_clazz.new(test_clazz, @filename) method = clazz.methods.find{ |m| m.name.to_s == test_method } method.run return method end |