Tests.json provide reference guide

You can determine what input data is provided to your program when the tests are run by using the provide property in the tests.json file

Example 9: providing input data

Lines 10-14 in Example 9 (above) tells the tests that every time the program asks for user input with the prompt What is your name?, the test will be provided with the input data Bob


You can provide a range of inputs for a self-marking test to use when it runs. The search property allows you to define what sort of input your test should be provided with:

input: when a test runs and a line of code that would usually ask the user to enter text, you can specify the value of that user input

file: when a test runs and line of code attempts to read the contents of a file, you can specify the value of that file

Defining what type of input to provide


If you don’t define a for property, the data you provide will be used every time the test tries to read from a file or ask the user for input (depending on the value of the search property).

If you want to only provide input if the user is asked a specific question, or when reading from a specific file, you can specify that question or file name using the for property

Example 10: providing input for a specific file

Lines 4-7 of Example 10 (above) mean that whenever the test is run and the code attempts to read from the file text.txt, the program will receive the data:

Line 1
Line 2
Line 3
Line 4
Line 5
instead of the data that the user normally sees in the file text.txt


The provide property defines what input data is provided to the program when the test runs, as long as the search and for criteria are met.

The next page explains how to link together your self-marking python challenges into trackers so that you and your students can track their progress and generate PDF certificates showing how many challenges they have completed.