Class: Mini::Test::TestCase

Inherits:
Object show all
Includes:
Assertions
Defined in:
lib/mini/test.rb

Direct Known Subclasses

Spec, Test::Unit::TestCase

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Assertions

#_assertions, #_assertions=, #assert, #assert_block, #assert_empty, #assert_equal, #assert_in_delta, #assert_in_epsilon, #assert_includes, #assert_instance_of, #assert_kind_of, #assert_match, #assert_nil, #assert_operator, #assert_raises, #assert_respond_to, #assert_same, #assert_throws, #capture_io, #exception_details, #fail, #message, #mu_pp, #pass, #refute, #refute_empty, #refute_equal, #refute_in_delta, #refute_in_epsilon, #refute_includes, #refute_instance_of, #refute_kind_of, #refute_match, #refute_nil, #refute_operator, #refute_respond_to, #refute_same

Constructor Details

#initialize(name) ⇒ TestCase

Returns a new instance of TestCase.



395
396
397
# File 'lib/mini/test.rb', line 395

def initialize name
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



376
377
378
# File 'lib/mini/test.rb', line 376

def name
  @name
end

Class Method Details

.inherited(klass) ⇒ Object



405
406
407
# File 'lib/mini/test.rb', line 405

def self.inherited klass
  @@test_suites[klass] = true
end

.resetObject



399
400
401
# File 'lib/mini/test.rb', line 399

def self.reset
  @@test_suites = {}
end

.test_methodsObject



417
418
419
420
421
422
423
424
425
426
427
428
# File 'lib/mini/test.rb', line 417

def self.test_methods
  methods = public_instance_methods(true).grep(/^test/).map { |m|
    m.to_s
  }.sort

  if self.test_order == :random then
    max = methods.size
    methods = methods.sort_by { rand(max) }
  end

  methods
end

.test_orderObject



409
410
411
# File 'lib/mini/test.rb', line 409

def self.test_order
  :random
end

.test_suitesObject



413
414
415
# File 'lib/mini/test.rb', line 413

def self.test_suites
  @@test_suites.keys.sort_by { |ts| ts.name }
end

Instance Method Details

#run(runner) ⇒ Object



378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
# File 'lib/mini/test.rb', line 378

def run runner
  result = '.'
  begin
    self.setup
    self.__send__ self.name
  rescue Exception => e
    result = runner.puke(self.class, self.name, e)
  ensure
    begin
      self.teardown
    rescue Exception => e
      result = runner.puke(self.class, self.name, e)
    end
  end
  result
end

#setupObject



430
# File 'lib/mini/test.rb', line 430

def setup; end

#teardownObject



431
# File 'lib/mini/test.rb', line 431

def teardown; end