class

Test

abstract class Test : Obj

Test is the base for Fantom unit tests.

See Fant.

constructors make

Protected constructor

methods curTestMethod

Get the current test method being executed or throw Err if not currently running a test

verifyEq

Verify that a == b, otherwise throw a test failure exception

verifyErr

Verify that the function throws an Err of the exact same type as errType (compare using === operator)

verifyNotEq

Verify that a != b, otherwise throw a test failure exception

verifyNull

Verify that a is null, otherwise throw a test failure exception

verifyTrue

Verify that cond is true, otherwise throw a test failure exception

fail

Throw a test failure exception

verifyErrMsg

Verify that the function throws an Err

verifySame

Verify that a === b, otherwise throw a test failure exception

setup

Setup is called before running each test method

tempDir

Return a temporary test directory which may used as a scratch directory

verify

Verify that cond is true, otherwise throw a test failure exception

teardown

Teardown is called after running every test method

verifyFalse

Verify that cond is false, otherwise throw a test failure exception

verifyNotNull

Verify that a is not null, otherwise throw a test failure exception

verifyNotSame

Verify that a !== b, otherwise throw a test failure exception

verifyType

Verify that Type.of(obj) equals the given type

curTestMethod Method curTestMethod()

Get the current test method being executed or throw Err if not currently running a test. This method is available during both setup and teardown as well as during the test itself.

fail Void fail(Str? msg)

Throw a test failure exception. If msg is non-null, include it in the failure exception.

make new make()

Protected constructor.

setup virtual Void setup()

Setup is called before running each test method.

teardown virtual Void teardown()

Teardown is called after running every test method.

tempDir File tempDir()

Return a temporary test directory which may used as a scratch directory. This directory is guaranteed to be created and empty the first time this method is called for a given test run. The test directory is "{Env.cur.tempDir}/test/".

verify Void verify(Bool cond, Str? msg)

Verify that cond is true, otherwise throw a test failure exception. If msg is non-null, include it in a failure exception. Identical to verifyTrue.

verifyEq Void verifyEq(Obj? a, Obj? b, Str? msg)

Verify that a == b, otherwise throw a test failure exception. If both a and b are nonnull, then this method also ensures that a.hash == b.hash, because any two objects which return true for equals() must also return the same hash code. If msg is non-null, include it in failure exception.

verifyErr Void verifyErr(Type? errType, |Test| c)

Verify that the function throws an Err of the exact same type as errType (compare using === operator). If the errType parameter is null, then this method tests only that an exception is thrown, not its type.

Example:

verifyErr(ParseErr#) { x := Int.fromStr("@#!") }

verifyErrMsg Void verifyErrMsg(Type errType, Str errMsg, |Test| c)

Verify that the function throws an Err. The Err must be the exact same type as errType and the contained msg must be the same as errMsg.

Example:

verifyErrMsg(ParseErr#, "Invalid Int: 'ABC'")
{
  x := Int.fromStr("ABC")
}

verifyFalse Void verifyFalse(Bool cond, Str? msg)

Verify that cond is false, otherwise throw a test failure exception. If msg is non-null, include it in a failure exception.

verifyNotEq Void verifyNotEq(Obj? a, Obj? b, Str? msg)

Verify that a != b, otherwise throw a test failure exception. If msg is non-null, include it in failure exception.

verifyNotNull Void verifyNotNull(Obj? a, Str? msg)

Verify that a is not null, otherwise throw a test failure exception. If msg is non-null, include it in a failure exception.

verifyNotSame Void verifyNotSame(Obj? a, Obj? b, Str? msg)

Verify that a !== b, otherwise throw a test failure exception. If msg is non-null, include it in failure exception.

verifyNull Void verifyNull(Obj? a, Str? msg)

Verify that a is null, otherwise throw a test failure exception. If msg is non-null, include it in a failure exception.

verifySame Void verifySame(Obj? a, Obj? b, Str? msg)

Verify that a === b, otherwise throw a test failure exception. If msg is non-null, include it in failure exception.

verifyTrue Void verifyTrue(Bool cond, Str? msg)

Verify that cond is true, otherwise throw a test failure exception. If msg is non-null, include it in a failure exception. Identical to verify.

verifyType Void verifyType(Obj obj, Type t)

Verify that Type.of(obj) equals the given type.

Haxall 4.0.5 ∙ 24-Feb-2026 14:33 EST