abstract class Testify::Test

Overview

Test class is equivalent of describe block (internally it's a mapping). It is an alternative DSL (Spec compliant) for creating unit and integration tests.

Any tests defined within a parent class will run for each child test case (by inheritance). Macros, abstract def, super and other OOP features can be used as well to reduce duplication.

Some additional features are also built in, such as the Data annotation and Tracker module.

See README for more details and examples.

Defined in:

testify.cr

Class Method Summary

Instance Method Summary

Class Method Detail

def self.run #

Runs the tests contained in the current Test class.

See Testify.run_all to run all tests contained in all the Test classes.

Instance Method Detail

def after_all : Nil #

Method executed after the last test in the current class runs.

class ExampleTest < Testify::Test
  def after_all : Nil
    puts "after_all"
  end
end

def after_each : Nil #

Method executed after each test in the current class runs.

class ExampleTest < Testify::Test
  def after_each : Nil
    puts "after_each"
  end
end

def around_all(procsy) : Nil #

Method executed when the current class runs.

class ExampleTest < Testify::Test
  def around_all(test) : Nil
    puts "around_all: before"
    test.run
    puts "around_all: after"
  end
end

def around_each(procsy) : Nil #

Method executed when each test in the current class runs.

class ExampleTest < Testify::Test
  def around_each(test) : Nil
    puts "around_each: before"
    test.run
    puts "around_each: after"
  end
end

def before_all : Nil #

Method executed before the first test in the current class runs.

class ExampleTest < Testify::Test
  def before_all : Nil
    puts "before_all"
  end
end

def before_each : Nil #

Method executed before each test in the current class runs.

class ExampleTest < Testify::Test
  def before_each : Nil
    puts "before_each"
  end
end