Class: CIAT::Suite
- Inherits:
-
Object
- Object
- CIAT::Suite
- Defined in:
- lib/ciat/suite.rb
Overview
A Suite of Tests
This is the top-level class for organizing CIAT tests. It can be used in a Rakefile
like so:
task :ciat do
CIAT::Suite.new(:processors => [compiler, executor]).run
end
You may find the CIAT::RakeTask a little bit easier and more familiar to use.
Specifying Test and Output Files and Folders
By default, this suite will do the following:
-
find tests ending in
.ciat
in a folder namedciat
, -
use simple standard-output feedback,
-
put all output files into a folder named
temp
, -
produce an HTML report in
temp/report.html
.
Each of these settings can be overridden with these options:
-
:processors
is required and specifies the processors to be executed; order matters! -
:folder
specifies folders to search for test files (default:ciat/**
). -
:pattern
specifies a pattern for matching test files (default:*.ciat
). -
:files
is an array of specific files (default: none). -
:output_folder
is the output folder (default:temp
) -
:report_filename
is the name of the report (default:report.html
in the output folder) -
:feedback
specifies a feedback mechanism (default: a CIAT::Feedback::StandardOutput).
:folder
and :pattern
can be used together; :files
overrides both :folder
and :pattern
.
Processors
You can create your own processors. Each processor needs to specify which test elements it wants or will accept, which files it wants checked, and how it should be executed. See CIAT::Processors::Java and CIAT::Processors::Parrot (to learn how to use them and how to write others).
Test File
See the README for details on the format of a test file.
Instance Attribute Summary collapse
-
#output_folder ⇒ Object
readonly
Returns the value of attribute output_folder.
-
#processors ⇒ Object
readonly
Returns the value of attribute processors.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#test_files ⇒ Object
readonly
Returns the value of attribute test_files.
Class Method Summary collapse
-
.build(options = {}) ⇒ Object
Builds a suite of CIAT tests.
Instance Method Summary collapse
- #create_test(test_file) ⇒ Object
-
#initialize(processors, output_folder, test_files, feedback) ⇒ Suite
constructor
A new instance of Suite.
-
#run ⇒ Object
Runs all of the tests in the suite, and returns the results.
-
#size ⇒ Object
Returns the number of tests in the suite.
Constructor Details
#initialize(processors, output_folder, test_files, feedback) ⇒ Suite
Returns a new instance of Suite.
75 76 77 78 79 80 |
# File 'lib/ciat/suite.rb', line 75 def initialize(processors, output_folder, test_files, feedback) @processors = processors @output_folder = output_folder @test_files = test_files @feedback = feedback end |
Instance Attribute Details
#output_folder ⇒ Object (readonly)
Returns the value of attribute output_folder.
60 61 62 |
# File 'lib/ciat/suite.rb', line 60 def output_folder @output_folder end |
#processors ⇒ Object (readonly)
Returns the value of attribute processors.
59 60 61 |
# File 'lib/ciat/suite.rb', line 59 def processors @processors end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
62 63 64 |
# File 'lib/ciat/suite.rb', line 62 def results @results end |
#test_files ⇒ Object (readonly)
Returns the value of attribute test_files.
61 62 63 |
# File 'lib/ciat/suite.rb', line 61 def test_files @test_files end |
Class Method Details
.build(options = {}) ⇒ Object
Builds a suite of CIAT tests. See the instructions above for possible values for the options
.
66 67 68 69 70 71 72 73 |
# File 'lib/ciat/suite.rb', line 66 def self.build( = {}) builder = CIAT::SuiteBuilder.new() CIAT::Suite.new( builder.build_processors, builder.build_output_folder, builder.build_test_files, builder.build_feedback) end |
Instance Method Details
#create_test(test_file) ⇒ Object
98 99 100 |
# File 'lib/ciat/suite.rb', line 98 def create_test(test_file) CIAT::Test.new(test_file, @processors, @feedback) end |
#run ⇒ Object
Runs all of the tests in the suite, and returns the results. The results are also available through #results.
89 90 91 92 93 94 95 96 |
# File 'lib/ciat/suite.rb', line 89 def run @feedback.pre_tests(self) @results = test_files. map { |test_file| create_test(test_file) }. map { |test| test.run } @feedback.post_tests(self) @results end |
#size ⇒ Object
Returns the number of tests in the suite.
83 84 85 |
# File 'lib/ciat/suite.rb', line 83 def size test_files.size end |