class Test::Case

include Test::Assertions

The base class of test cases: an instance is made for each test. quarz test runs every public test_* method of a class that inherits it (docs/12-testing.md); a field with an initializer is a fixture, fresh for each test.

class ExampleStackTest < Test::Case
  @items: Array[Int] = [1, 2]

  def test_push
    assert_equal([1, 2, 3], @items.push(3))
  end

  def test_fetch
    e = assert_raise(IndexError) { puts @items[5] }
    assert_match(/out of bounds/, e.message)
  end
end

<std:test>:345

Class methods

def self.startup -> Void

Runs once before the class's first test; when it raises, every test of the class is an error.

<std:test>:360

def self.shutdown -> Void

Runs once after the class's last test, unless .startup raised.

<std:test>:362

def self.timeout -> Duration?

The class's limit per test (nil: the run's).

<std:test>:365

def self.serial? -> Bool

Whether the class's tests must run one at a time (--parallel).

<std:test>:368

Methods

def setup -> Void

Runs before each test, on the test's fresh instance; does nothing unless a test class overrides it.

<std:test>:353

def teardown -> Void

Runs after each test, on its instance, also after a failure or an error: it undoes what #setup did.

<std:test>:356

def assertion_count -> Int

The number of assertions the test has made.

<std:test>:371

def notes -> Array[String]

The notes #notify added, in order.

<std:test>:373

def add_assertion -> Void

Counts one assertion made: each assertion calls it once, and Test::Case counts its test's.

from Test::Assertions

<std:test>:375

def notify(message: String) -> Void

A note shown in the report.

<std:test>:381