← index

TestSuite

inherits Object · defined at test.qn:383

A named group of tests — the unit a test file declares. Constructing one registers it in the global [Test]Suites registry, so a file just builds its suite and qn test collects and runs everything registered.

(TestSuite.new:{ var name = 'Math' }).add:{
    .test:
    addition -> {
        .is:{ 1 + 1 } equalTo:2
    }
}

Instance methods

add:Block

Declare the suite's contents: the block runs with the suite as self, so bare .test: (and .skip:) sends inside it land here. Answers self.

test.qn:463

init:String

Register the new suite under name in [Test]Suites — registration IS construction; there is no separate register call.

test.qn:386

name

The suite's name, shown as the [Tag] in reporter output.

test.qn:399

reason

The reason passed to skip:, or nil when the suite runs.

test.qn:417

runSetup

Internal: run the setup: blocks, in declaration order. TestRunner calls this before each test; a skipped suite's hooks never run.

test.qn:452

runSetupAll

Internal: run the setupAll: blocks, in declaration order.

test.qn:456

runTeardown

Internal: run the teardown: blocks, in reverse declaration order.

test.qn:454

runTeardownAll

Internal: run the teardownAll: blocks, in reverse declaration order.

test.qn:458

s

A TestSuite prints as its name.

test.qn:401

setup:Block

Declare a block to run before EACH test — per-test fixture construction. Share state with the tests the ordinary way: capture a var from the enclosing scope. Multiple setup: blocks run in declaration order. Answers self.

test.qn:423

setupAll:Block

Declare a block to run ONCE, before the suite's first test — for a fixture every test shares read-only (build files, start a server). Multiple setupAll: blocks run in declaration order. Answers self.

test.qn:438

skip:String

Mark this whole suite skipped, with a human-readable reason (e.g. an optional native extension or driver isn't installed on this machine). A skipped suite registers no tests: the runner reports it as SKIPPED and it counts as neither a pass nor a failure, so the overall run stays green. Call it from an .add: block, typically in the else: of an availability check.

test.qn:408

skipped?

true once skip: has marked the suite.

test.qn:415

teardown:Block

Declare a block to run after EACH test — the setup:'s undo, run whether or not the test's assertions passed. Multiple teardown: blocks run in REVERSE declaration order (last declared, first run — teardowns unwind). Answers self.

test.qn:431

teardownAll:Block

Declare a block to run ONCE, after the suite's last test — remove what setupAll: built. Multiple teardownAll: blocks run in REVERSE declaration order. Answers self.

test.qn:445

test:Method

Add one test: m is a method literal (name -> { … }) whose body makes assertion sends and whose selector names the test. The method may declare at most one parameter.

test.qn:471

tests

The Tests declared so far, in declaration order.

test.qn:481