afAxontExt icon

afAxontExt

Unit test runner and assertion functions for Axon
afAxontExtAxon funcs

Registered StackHub users may elect to receive email notifications whenever a new package version is released or a comment is posted on the forum.

There are 2 watchers.

v0.1.0

fail
fail(msg: null)

Throw a test failure exception.

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

Fantom signature:
@Axon static Void fail(Obj? msg := null)
runTests
runTests(tests, options: null)

Runs the given list of test functions and returns a Grid of results.

tests may be a name of a top level function, the function itself, or a list of said types.

options is a Dict which may contains the following:

  • setup - a func that is run before every test function
  • teardown - a func that is run after every test function
Fantom signature:
@Axon static Grid runTests(Obj tests, Dict? options := null)
tests
tests()

Returns a list of all top level funcs in the project whose name starts with test. Use to quickly run all tests in a project.

Example:

tests().runTests()
Fantom signature:
@Axon static Fn[] tests()
verify
verify(cond, msg: null)

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().

Fantom signature:
@Axon static Void verify(Bool cond, Str? msg := null)
verifyEq
verifyEq(a, b, msg: null)

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

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

Fantom signature:
@Axon static Void verifyEq(Obj? a, Obj? b, Str? msg := null)
verifyErr
verifyErr(fn)

Verify that the function throws an Err. The err msg is returned so you may do further (regex) tests on it.

Example:

verifyErr =>
  parseInt("@#!")
Fantom signature:
@Axon static Str verifyErr(Fn fn)
verifyErrMsg
verifyErrMsg(errMsg, fn)

Verify that the function throws an Err. The contained dis msg must be the same as errMsg.

Example:

verifyErrMsg("Invalid Int: '@#!'") () =>
  parseInt("@#!")

verifyErrMsg("poo") () =>
  throw { dis: "poo" }
Fantom signature:
@Axon static Void verifyErrMsg(Str errMsg, Fn fn)
verifyFalse
verifyFalse(cond, msg: null)

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

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

Fantom signature:
@Axon static Void verifyFalse(Bool cond, Str? msg := null)
verifyNotEq
verifyNotEq(a, b, msg: null)

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

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

Fantom signature:
@Axon static Void verifyNotEq(Obj? a, Obj? b, Str? msg := null)
verifyNotNull
verifyNotNull(a, 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.

Fantom signature:
@Axon static Void verifyNotNull(Obj? a, Str? msg := null)
verifyNull
verifyNull(a, msg: null)

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

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

Fantom signature:
@Axon static Void verifyNull(Obj? a, Str? msg := null)
verifyTrue
verifyTrue(cond, msg: null)

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().

Fantom signature:
@Axon static Void verifyTrue(Bool cond, Str? msg := null)
Published by Fantom Factory

Products & Services by Fantom Factory

Packages by Fantom Factory

Commercial packages

Free packages