Class: Rake::FitTask
- Inherits:
-
TaskLib
- Object
- TaskLib
- Rake::FitTask
- Defined in:
- lib/fittask.rb
Overview
Create a task that runs a set of FIT tests.
If rake is invoked with an ATEST command line option, then the list of test files will be overridden to include only the filename specified on the command line. This provides an easy way to run just one test. The exact syntax of the ATEST option is as follows:
ATEST=/path/to/FileHtml:Right:Wrong:Ignores:Exceptions:Encoding
where you can include a path to the HTML file, which must be specified without the .html extension; where Rights, Wrong, Ignores and Exceptions are the numbers of the expected results from the test run; and where Encoding is the character encoding of the input file. Note that the report path will be the same as the test path.
Defined Under Namespace
Classes: AcceptanceTestSuite
Instance Attribute Summary collapse
-
#fail_on_failed_test ⇒ Object
Returns the value of attribute fail_on_failed_test.
-
#libs ⇒ Object
Returns the value of attribute libs.
-
#name ⇒ Object
Returns the value of attribute name.
-
#pattern ⇒ Object
Returns the value of attribute pattern.
Instance Method Summary collapse
- #create_test_suite(&block) ⇒ Object
- #define(task_name) ⇒ Object
-
#initialize(name = :fittest) {|_self| ... } ⇒ FitTask
constructor
A new instance of FitTask.
- #test_suites ⇒ Object
- #test_suites=(list) ⇒ Object
Constructor Details
#initialize(name = :fittest) {|_self| ... } ⇒ FitTask
Returns a new instance of FitTask.
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/fittask.rb', line 68 def initialize(name=:fittest) @name = name @libs = ["lib"] @pattern = nil @test_files = [] @test_suites = [] @fail_on_failed_test=false @tests_failed=false yield self if block_given? define name end |
Instance Attribute Details
#fail_on_failed_test ⇒ Object
Returns the value of attribute fail_on_failed_test.
46 47 48 |
# File 'lib/fittask.rb', line 46 def fail_on_failed_test @fail_on_failed_test end |
#libs ⇒ Object
Returns the value of attribute libs.
46 47 48 |
# File 'lib/fittask.rb', line 46 def libs @libs end |
#name ⇒ Object
Returns the value of attribute name.
46 47 48 |
# File 'lib/fittask.rb', line 46 def name @name end |
#pattern ⇒ Object
Returns the value of attribute pattern.
46 47 48 |
# File 'lib/fittask.rb', line 46 def pattern @pattern end |
Instance Method Details
#create_test_suite(&block) ⇒ Object
120 121 122 123 124 |
# File 'lib/fittask.rb', line 120 def create_test_suite &block suite = AcceptanceTestSuite.new block.call suite @test_suites << suite end |
#define(task_name) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/fittask.rb', line 80 def define task_name # describe the fit task desc "Run FIT acceptance tests" task task_name # silence footnote creation since we don't want HTML reports task task_name do Fit::Parse.send(:define_method, 'footnote', lambda {''}) end # define a fit task for each test suite test_suites.each do |suite| task task_name do @tests_failed = true unless suite.run_tests end end task task_name do raise 'Tests failed.' if @fail_on_failed_test && @tests_failed end # describe the fit_report task desc "Run FIT acceptance tests with HTML reports" task_report_name = (task_name.to_s + '_report').to_sym task task_report_name # define a fit_report task for each test suite test_suites.each do |suite| task task_report_name do # set footnote path to an appropriate location Fit::Parse.footnote_path = suite.report_path # run tests @tests_failed = true unless suite.run_tests_with_reports end end task task_report_name do raise 'Tests failed.' if @fail_on_failed_test && @tests_failed end self end |
#test_suites ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/fittask.rb', line 52 def test_suites if ENV['ATEST'] atest = ENV['ATEST'].split ':' filename = atest[0] test_name = File.basename(filename) test = { :name => test_name, :right => atest[1].to_i, :wrong => atest[2].to_i, :ignores => atest[3].to_i, :exceptions => atest[4].to_i, :encoding => atest[5] } suite = AcceptanceTestSuite.new suite << test suite.test_path = suite.report_path = File.dirname(filename) + File::SEPARATOR [suite] else @test_suites end end |
#test_suites=(list) ⇒ Object
48 49 50 |
# File 'lib/fittask.rb', line 48 def test_suites=(list) @test_suites = list end |