Test Cases

Test Cases check students work upon submission or when they use the check code button

Kayla Pica avatar
Written by Kayla Pica
Updated over a week ago
Free Feature

CodeHS runs student programs through a series of Test Cases to ensure that their code is functionally, and stylistically sound while accomplishing the goals of a given exercise. 

Image showing Test Cases and Check Code

How It Works:

When a student hits the ‘Submit Code’ button, the Test Cases are run against our Autograders, and if any fail, the student is prevented from submitting their code for grading.

Students and teachers can see these Test Cases when they visit the "Test Cases" tab in the top right corner of any exercise page, or when they click Submit + Continue upon completing an exercise. The progress bar under the blue Check Code button also shows how many test cases the student has passed.

Student program showing Test Cases

**Important Note: Test Cases are not designed to catch all errors/issues all of the time. We think about Test Cases like Spell Check. Spell Check ensures that the basic spelling and sentence mechanics are correct, but simply because something passes Spell Check doesn't mean that the entire essay is logically sound. 

In the same way, Test Cases are meant to be a first line of checks to point students in the right direction, but often teachers will want to grade student programs themselves to ensure they are functionally and stylistically correct.

Creating Your Own Test Cases:

With CodeHS Create, you can define your own Test Cases for an assignment you create for your students. These Test Cases are different for every language. In each case, you’ll be able to test the content of the student’s code, as well as the result that their code produces, whether that is a graphics canvas, a string, or a webpage. For more information, check out Autograders or Creating Your Own Autograders

Still have questions? Contact our team at hello@codehs.com to learn more!

Did this answer your question?