Skip to content
6.2.4. Unit Testing

6.2.4. Unit Testing


ELPS provides support for automated testing with package testing. It has facilities to define tests, run them and report the results. Tests are simply elps code.

Defining tests

The core of the testing package is the test macro that allows you define a test. It takes as first argument a string that describes what functionality it tests. The body can be arbitrary elps code.

A simple test looks like this:

To write a new test suite, you should create a file whose name ends with _test.lisp.


The example above uses the macro assert-equal to assert the result of the test. Assertions allow you to easily write test code. The testing package provides the following macros for assertion:

  • assert=

Asserts that the specified numbers are equal.

  • assert-string=

Asserts that the specified strings are lexicographically equal.

  • assert-equal

Asserts that the specified objects are equal.

  • assert-nil

Asserts that the specified object is nil.

  • assert-not-nil

Asserts that the specified object is non-nil.

  • assert-not

Asserts that the argument is false

Running tests

There are two ways to run tests depending on whether you are using the ELPS standard library only or functions available in libraries provided by Luther's substrate platform.

  • Elpstest Runner (Golang)

A simple test function using the runner looks like this:

func TestPackage(t *testing.T) {
    r := &elpstest.Runner{}
    r.RunTestFile(t, "package_test.lisp")

This is intended to be used with the go test command, and does not depend on substrate.

  • Shirotester

This is a tool provided as a docker image that you can run locally to execute elps test files in the current directory.

docker run -v ${PWD}:/tmp -w /tmp unit-tests .

Note this requires a main.lisp in the same directory as the test and must be in the same package.

It initialises the test environment with substrate functions.

We use cookies to give you the best experience of using this website. By continuing to use this site, you accept our use of cookies. Please read our Cookie Policy for more information.