Create an IO Test

Check that the output of a program matches the expected output

IO Tests allow you to compare the output of a program with an expected output provided a specific set of inputs to the program. If the program returns the same output as the specified expected output, the test passes. IO tests are a great way to check that your students' programs function the way you expect them to.

You can easily create IO Tests in AutoTest v2 using a combination of the IO Test wrapper block and one of the three Match blocks. Simply nest the Match blocks within the IO Test wrapper block and create different test cases by providing different inputs in each Match block.

AutoTest v2 provides a number of different ways to match the output of a program. This is done through the three available Match blocks:

  • The Full Match block - This checks if the entire stdout of the program matches the expected output.

  • Substring match - This checks that the expected output is a substring of the stdout of the program

  • Regex match - This checks that the regular expression is found in the stdout of the program.

How to add an IO Test to your AutoTest configuration:

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

  2. Add the IO Test wrapper block by clicking on it in the block list panel to add it to the bottom of your AutoTest config, or drag-and-drop the block to the desired location.

  3. Add one of the three available match blocks by nesting it within the IO Test block.

  4. Provide the program to execute in the editor provided in the IO test block.

  5. Provide any inputs required for the program to run in the Input field of the Match block.

  6. Provide the expected output in the Expected output field of the Match block.

  7. Finally, adjust the case sensitivity and the whitespace options using the dropdown menus in the Match block.

You can nest as many Match blocks within an IO Test block to provide different inputs to the program and test different outcomes.

You can use uploaded files as input arguments too, access them in the $UPLOADED_FILESdirectory.

Last updated