What are test cases?

What are test cases?

Test cases are an important part of both Labs and Projects. They're a structured way of informing students what their solution can take as input and what the output must be. Both input and output can either be files or console based I/O.

For each question, instructors must have at least 1 test case but we recommend that there be a few more. Test cases can also be hidden from students so that they do not hard code the test cases into their solution.

A single test case can have up to 3 parts: console, input files, and output files. The console part of the test case dictates what the console should look like when the solution is run. This includes the output from the program as well as the user input. To differentiate between the two, the user input is highlighted in blue.

The input files are available to the program to read from. The program can read the file in the same directory as it is running in with the filename as shown in the test case.

If a test case includes output files, it means the solution is expected to output those files with the same filename and contents. These files will not be made available to the solution to read from. They're used to compare the solution's output files with the ones in the test case.

Example #1:

The screenshot above shows a set of 2 simple test cases that only deal with console I/O. The first test case is visible to students whereas the second test case is hidden.

We can see in the first test case that the solution is expected to print out a prompt in response to which there is a user input. User input is highlighted in blue. The solution is expected to read this in as stdin.

Example #2

The screenshot above shows a test case that has both console I/O as well as file I/O. The solution is expected to read in a file name using stdin and then write the contents of the file to output.txt.

results for ""

    No results matching ""