Skip to content

A basic example of running tests (and fixing a typo)

Henrik Lindberg edited this page Oct 1, 2017 · 1 revision

Here's a basic example of using the run-tests command of $CLI_JAR. Download a "Hello world" zip file from the MOOC site, extract it and cd into the new directory Week0/0_0_helloworld. Run make clean to avoid an error condition and then java -jar "$CLI_JAR" run-tests --exercisePath . --outputPath results.txt. You can view the test results with cat results.txt.

Experiment by changing a line in the file test/test_source.c: char* rightString = "Hei maailma!\n"; // No longer "Hello World!"

Repeat the run-tests command. The content of results.txt should now indicate a test failure.

A part of one of the lines produced by run-tests is MakePlugin:213 - Running tests with command {0}. The zero between the two braces seems to be a typo by a developer. Let's correct the error just to get a feel of how to modify tmc-langs. Find the file to edit with find ~/tmc/tmc-langs-master -name MakePlugin.java, open it with a text editor, correct the typo on line 213 and recompile with mvn clean package -DskipTests. Now the line in question produced by run-tests should end with MakePlugin:213 - Running tests with command [make, run-test]. Better!