Skip to main content
All CollectionsAutograders CodeHS Autograders
General Autograder Test Cases and Unit Tests on CodeHS
General Autograder Test Cases and Unit Tests on CodeHS

Learn about the difference between Test Cases in Coding Exercises and Unit Test Exercises

Sara Jenis avatar
Written by Sara Jenis
Updated over a year ago

General Autograder Test Cases

CodeHS runs student programs through a series of Test Cases to ensure that their code is functionally and stylistically sound, and accomplishes the goals of a given exercise. 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.

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

CodeHS allows teachers to create customized autograders to help grade student work - read Creating Your Own Autograders for more information.

Unit Test Test Cases - Similar, but Different

The Test Cases for Unit Test assignments work a little differently. These are used with Unit Test exercises, where the student is usually asked to write a specific function or small unit of code.

image showing Test Cases in Unit Test probelm

What is a Unit Test?

A Unit Test is a type of exercise which is simpler than a full program and allows you to test a single concept much easier. CodeHS Practice Assignments are good examples of Unit Tests. Any type of assignment that is designated Practice, is technically a Unit Test.

Unit Tests have Test Cases which pass values through the student's function and compare these outputs to the outputs when these values are passed through the exercise solution. If the values don't match, the student will see a message showing that their function did not generate the expected result. When the student passes all Test Cases, they will turn green signaling that the student completed the assignment successfully!

Unit Tests in CodeHS Courses

When working through our curriculum, students might come across exercises that have two files: a Unit Test file and a Scratchpad file. In these assignments, Unit Test is the file which is graded by the autograder or the teacher, and Scratchpad is ungraded. Here's an example from our Java course, 3.3.4 Double Number:

See Create a Custom Practice Problem to learn more about creating these problems.


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


Did this answer your question?