Print this chapterPrint this chapter

CodeRunner Documentation (V3.2.1)

2.6 Running the unit tests

If your Moodle installation includes the phpunit system for testing Moodle modules, you might wish to test the CodeRunner installation. Most tests require that at least python2 and python3 are installed.

Before running any tests you first need to copy the file <moodlehome>/question/type/coderunner/tests/fixtures/test-sandbox-config-dist.php to '/question/type/coderunner/tests/fixtures/test-sandbox-config.php', then edit it to set whatever configuration of sandboxes you wish to test, and to set the jobe host, if appropriate. You should then initialise the phpunit environment with the commands

    cd <moodlehome>
    sudo php admin/tool/phpunit/cli/init.php

You can then run the full CodeRunner test suite with one of the following two commands, depending on which version of phpunit you're using:

    sudo -u www-data vendor/bin/phpunit --verbose --testsuite="qtype_coderunner test suite"

or

    sudo -u www-data vendor/bin/phpunit --verbose --testsuite="qtype_coderunner_testsuite"

If you're on a Red Hat or similar system in which the web server runs as apache, you should replace www-data with *apache.

TThe unit tests will almost certainly show lots of skipped or failed tests relating to the various sandboxes and languages that you have not installed, e.g. the LiuSandbox, Matlab, Octave and Java. These can all be ignored unless you plan to use those capabilities. The name of the failing tests should be sufficient to tell you if you need be at all worried.

Feel free to email the principal developer if you have problems with the installation.