Skip to content
Nane Kratzke edited this page Nov 28, 2018 · 24 revisions

JEdUnit is a unit testing framework with a specific focus on educational aspects. It strives to simplify automatic evaluation of (small) Java programming assignments using Moodle and VPL.

We developed this framework mainly for our purposes in programming classes at the Lübeck University of Applied Sciences. However, this framework might be helpful for other programming instructors. Therefore, we provide it as open source.

Intended audience and usage

This framework is for programming instructors and teachers at schools, colleges, universities or further programming training facilities that want (or need) to automatically evaluate and grade (small) Java programming assignments typically at a "freshman" (1st/2nd semester) level.

We assume the reader to be familiar with Java in general.

Quick start:

The following workflow is recommended to set up a new programming assignment.

  1. Initialize an assignment locally
  2. Adapt the example
  3. Validate your assignment locally
  4. Import the assignment into Moodle as a VPL task

Initialize an assignment locally

First of all, initialize a directory on your local machine and then run:

curl -s https://raw.githubusercontent.com/nkratzke/VPL-java-template/working/init.sh | sh

This script will initialize a new programming assignment with all necessary dependencies in a similar way the VPL plugin processes the assignment. This script will print the following to your console

Downloading JEdUnit
Downloading Checkstyle
Initializing assignment
Preparing style_checks.xml
Preparing vpl_evaluate.sh
Preparing vpl_run.sh
Preparing clean.sh
Preparing Main.java
Preparing Solution.java
Preparing Checks.java

The following three files are of vital importance:

  • Main.java is the file provided to students. Students should extend this file with their submission (for single file submissions).
  • Solution.java is the file where the reference solution is defined. Students are not aware of this file.
  • Checks.java defines the evaluation logic and test data generation. This file normally uses the Solution.java file for correctness checks.

The created template contains an entirely running example assignment (a countChars() method that should count a specific character c in a string s).

Adapt the running example

Usually, you will evolve and modify the running example to create your assignments. If these are your first steps, you can skip this section. This Wiki provides further paragraphs that will explain how you can

Validate your assignment logic locally

To emulate the VPL run command you can do the following:

./vpl_run.sh
./vpl_execution

To emulate the VPL evaluate command you can do the following:

./vpl_evaluate.sh
./vpl_execution

This will generate the following (shortened) output on your console:

Comment :=>>JEdUnit 0.1.23
Comment :=>>
Comment :=>>- Checkstyle
Comment :=>>Everything fine
Comment :=>>Current percentage: 0%
Grade :=>> 0
[...]
Comment :=>>- [25,00%]: Provided example calls
Comment :=>>Check 1: [FAILED] countChars('o', "Hello⎵World") should return 2. but returned -1. (0 of 5 points)
Comment :=>>Check 2: [FAILED] countChars('w', "Hello⎵World") should return 1. but returned -1. (0 of 5 points)
Comment :=>>Result for this test: 0 of 10 points (0%)
Comment :=>>Current percentage: 0%
Grade :=>> 0
Comment :=>>
Comment :=>>- [25,00%]: Boundary testcases (unknown test cases)
Comment :=>>Check 3: [FAILED] countChars('x', "") should return 0. but returned -1. (0 of 10 points)
Comment :=>>Check 4: [FAILED] countChars('X', "") should return 0. but returned -1. (0 of 10 points)
[...]
Comment :=>>Check 10: [FAILED] countChars('x', "Xa") should return 1. but returned -1. (0 of 5 points)
Comment :=>>Result for this test: 0 of 50 points (0%)
Comment :=>>Current percentage: 0%
Grade :=>> 0
Comment :=>>
Comment :=>>- [50,00%]: Randomized testcases
Comment :=>>Check 11: [FAILED] countChars('m', "mmmG!!v!!!&T?c") should return 3. but returned -1. (0 of 5 points)
Comment :=>>Check 12: [FAILED] countChars('M', "mmm!§?!!&?§§?§") should return 3. but returned -1. (0 of 5 points)
[...]
Comment :=>>Check 18: [FAILED] countChars('M', "§?M&!!s!QK&§NS§hmm$O§B$!$$") should return 3. but returned -1. (0 of 5 points)
Comment :=>>Result for this test: 0 of 40 points (0%)
Comment :=>>Current percentage: 0%
Grade :=>> 0
Comment :=>>
Comment :=>>Finished: 0 points

So, vpl_run.sh and vpl_evaluate.sh can be used to check your assignment evaluation logic locally. The lines starting with Comment :=>> and Grade :=>> are generated by JEdUnit and will be interpreted by the Moodle VPL plugin if run in a Moodle context.

Import the assignment into Moodle as a VPL task

The VPL documentation is ... well ... "fragmented". Therefore, we recommend studying at least the following VPL related documentation before you create your first VPL assignment in Moodle:

However, a JEdUnit template is a good starting point. If the output as mentioned above is generated follow these steps:

  1. Import the following requested files Main.java via the Moodle web interface from this repository as a starting point for your students.
  2. Import the following execution files via the Moodle web interface from this directory
    • Checks.java
    • Solution.java
    • style_checks.xml
    • vpl_evaluate.sh
    • vpl_run.sh
    • jedunit.jar
    • checkstyle.jar
  3. !!!IMPORTANT!!! Select jedunit.jar as a to be kept file via the Moodle web interface (otherwise your evaluation will not work).

Moodle Tip

It is recommended to do these settings only once for a Moodle course and to derive all your assignments via the "based-on" feature of the Moodle VPL plugin. So, you only need to import the assignment specific files

  • Main.java (as necessary file)
  • Checks.java (as execution file)
  • Solution.java (as execution file)