Class: CIAT::Suite

Inherits:
Object
  • Object
show all
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 named ciat,

  • 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

Class Method Summary collapse

Instance Method Summary collapse

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_folderObject (readonly)

Returns the value of attribute output_folder.



60
61
62
# File 'lib/ciat/suite.rb', line 60

def output_folder
  @output_folder
end

#processorsObject (readonly)

Returns the value of attribute processors.



59
60
61
# File 'lib/ciat/suite.rb', line 59

def processors
  @processors
end

#resultsObject (readonly)

Returns the value of attribute results.



62
63
64
# File 'lib/ciat/suite.rb', line 62

def results
  @results
end

#test_filesObject (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(options = {})
  builder = CIAT::SuiteBuilder.new(options)
  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

#runObject

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

#sizeObject

Returns the number of tests in the suite.



83
84
85
# File 'lib/ciat/suite.rb', line 83

def size
  test_files.size
end