Class: TTK::Strategies::Suite

Inherits:
Collection show all
Includes:
Concrete, Ordered
Defined in:
lib/ttk/strategies/Suite.rb

Overview

An ordered collection of tests which can be #run.

A the Suite class has two goals:

- group a set of Strategy in a single object which is a Strategy.
- factor some attributes which are identical in each tests of the
  the suite.

Example

require 'ttk'
include TTK

symtbl = TTK::SymTbl.new
symtbl[:loader] = Loaders::Yaml.new
aSuite = Strategies::Suite.new({
          :name   => 'A set of tests',
          :symtbl => symtbl,
          :wclass => Weights::WFloat,
          :attributes => {
              :strategy => Strategies::Cmd,
              :exit  => 0
            },
            :contents => OHash[
              "I'm suppose to pass 1", { :command => "true" },
              "I'm suppose to fail 2", { :command => "false", :weight => -1 },
              "I'm suppose to pass 3", { :command => "false",
                                         :exit    => 1 }
            ]
        })
aSuite.run(Logger.new(Dumpers::Yaml.new(STDOUT)))

aSuite = Strategies::Suite.new
aSuite.name = 'A set of tests'
aSuite.symtbl = symtbl
aSuite.wclass = Weights::WFloat
aSuite.strategyclass = Strategies::Cmd
aSuite.exit = 0    # a sugar when its unambiguous.
t1 = aSuite.create
t1.name = "I'm suppose to pass 4"
t1.command = "true"
aSuite.create({ :name    => "I'm suppose to fail 5",
                :command => "false",
                :weight  => -1 })
io = Tempfile.new('ttk-example')
io << << EOF
---
name: I'm suppose to pass 6
command: false
exit: 1
EOF
io.rewind
aSuite.create(io)
aSuite.run(Logger.new(Dumpers::Yaml.new(STDOUT)))

Instance Attribute Summary

Attributes inherited from Strategy

#status, #symtbl

Method Summary

Methods inherited from Collection

#attributes=, #contents=, #create, #initialize, #method_missing, #strategyclass, #strategyclass=

Methods inherited from Composite

#<<, #create, #initialize, #initialize_test, #new_symtbl

Methods inherited from Strategy

#abort, #assign, #clean_instance_variables, #display_unexpected_exc, #display_unexpected_synflow_exc, #fail, #initialize, #initialize_flow_factory, #pass, #raise_error, #reject, #run, #running?, #skip, #skip_if_cached, #strategy, #strategy=, #symbols=, #testify, #timeout=, #to_s, #wclass=

Constructor Details

This class inherits a constructor from TTK::Strategies::Collection

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class TTK::Strategies::Collection