An Exercism test runner automatically verifies if a submission passes all the tests.
This repository contains the Java test runner, which implements the V3 spec of the test runner interface.
To run the tests of an arbitrary exercise, do the following:
- Open a terminal in the project's root
- Run
./bin/run.sh <exercise-slug> <solution-dir> <output-dir>
Once the test runner has finished, its results will be written to <output-dir>/results.json.
The test runner compiles solutions with a native javac when the NATIVE_JAVAC_PATH environment variable holds the path of the executable. The Docker image sets it to /opt/test-runner/native-javac/javac (see bin/build-native-javac.sh).
To use a native javac when running without Docker, set the variable to the path of your build. The lib/ct.sym file must be in the lib folder next to the executable.
If the variable is unset, the file is missing or the native javac fails, the test runner compiles with the JVM's own javac.
This script is provided for testing purposes, as it mimics how test runners run in Exercism's production environment.
To run the tests of an arbitrary exercise using the Docker image, do the following:
- Open a terminal in the project's root
- Run
./bin/run-in-docker.sh <exercise-slug> <solution-dir> <output-dir>
Once the test runner has finished, its results will be written to <output-dir>/results.json.
To run the tests to verify the behavior of the test runner, do the following:
- Open a terminal in the project's root
- Run
./bin/run-tests.sh
These are golden tests that compare the results.json generated by running the current state of the code
against the "known good" tests/<test-name>/expected_results.json.
All files created during the test run itself are discarded.
When you've made modifications to the code that will result in a new "golden" state,
you'll need to generate and commit a new tests/<test-name>/expected_results.json file.
This script is provided for testing purposes, as it mimics how test runners run in Exercism's production environment.
To run the tests to verify the behavior of the test runner using the Docker image, do the following:
- Open a terminal in the project's root
- Run
./bin/run-tests-in-docker.sh
These are golden tests that compare the results.json generated by running the current state of the code
against the "known good" tests/<test-name>/expected_results.json.
All files created during the test run itself are discarded.
When you've made modifications to the code that will result in a new "golden" state,
you'll need to generate and commit a new tests/<test-name>/expected_results.json file.