Fan

 

abstract class

sys::Test

sys::Obj
  sys::Test

Test is the base for Fan unit tests.

Slots

failSource

Void fail(Str? msg := null)

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

idSource

Str id()

Get a unique id for this run of the test method. This id is guaranteed to be unique for the life of the VM.

makeSource

new make()

Protected constructor.

setupSource

virtual Void setup()

Setup is called before running each test method.

teardownSource

virtual Void teardown()

Teardown is called after running every test method.

tempDirSource

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 "{Repo.working}/test/".

verifySource

Void verify(Bool cond, Str? msg := null)

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

verifyEqSource

Void verifyEq(Obj? a, Obj? b, Str? msg := null)

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.

verifyErrSource

Void verifyErr(Type errType, |Test| c)

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

Examples:

verifyErr(ParseErr#) { Int.fromStr("@#!") }
verifyFalseSource

Void verifyFalse(Bool cond, Str? msg := null)

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

verifyNotEqSource

Void verifyNotEq(Obj? a, Obj? b, Str? msg := null)

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

verifyNotNullSource

Void verifyNotNull(Obj? a, Str? msg := null)

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

verifyNotSameSource

Void verifyNotSame(Obj? a, Obj? b, Str? msg := null)

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

verifyNullSource

Void verifyNull(Obj? a, Str? msg := null)

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

verifySameSource

Void verifySame(Obj? a, Obj? b, Str? msg := null)

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