Create a Custom Test

Run a custom test using any testing framework and output the result in a structured output format.

The Custom test block allows you to run any number of tests and output their result in a structured way. In comparison, other test steps only allow you to test one thing. In order to do this the Custom Test block checks for a JSON object that specifies the number of tests passed and the total number of tests and uses this to determine the final points scored.

You can use the custom test block in many ways, including:

  • Running unit tests with a custom framework .

  • Running code quality tests and adding automatic comments on your students' code.

  • Running memory leak checks or other performance tests.

How to add a Custom Test to your AutoTest configuration:

  1. Navigate to the Tests tab in the AutoTest settings.

  2. Click to add the Custom Test block to the bottom of your AutoTest or drag-and-drop the block to the desired location.

  3. Using the provided editor, run your own custom grading script or simple bash tests and output the results for parsing.

  4. Using the results of the test, parse the test results in the required JSON format to declare the number of points that should be awarded. The JSON object should have the following parameters:

    • Tag (string) - This should always be "points".

    • Points (float) - This should be a float between 0 and 1 and can also be written as a fraction (e.g. "5/10").

  5. Nest this block within a Connect Rubric block to make sure it counts towards your students' final grade.

import json

with open(3, 'w') as f:
            "tag": "points",
            "points": 0.45

Last updated