For teachers

Test cases

A program question is marked by running the student's program. Each test case gives the program some input and says what it should produce. The results decide the mark.

What you set for each test case

  • Test Case Name. A name for this case, so a failure tells you which case did not pass.
  • Arguments and Standard Input. What the program is given when it runs.
  • Expected Output. What the program must produce to pass.
  • Maximum CPU Time and Memory Permitted. Limits in milliseconds and kilobytes. A program that never finishes fails the case instead of running forever.

Write more than one

With only one test case, a student can pass by guessing the shape of your example. Several test cases show whether the program really works.

Useful ones to include:

  • Empty input. Many programs fail here.
  • A single item. Loops often behave differently with one value.
  • One past the end. This is where an almost-correct program usually breaks.

Giving partial marks

By default a program question is all or nothing.

Turn on Score/Mark at test case level and each case gets its own Mark/Score and Negative Mark/Score.

This changes what the question measures. All or nothing asks whether the program is correct. Marks per case show how far each student got, which is usually more useful while you are still teaching the topic.

What next

Once your questions and test cases are ready, the evaluation method decides how much marking is done for you.

Test cases is the reference version of this page.

This website uses cookies to ensure you get the best experience on our website.