# How to Write a Unit Test Problem on CodeHS
Published: 2016-09-24
Category: HS/MS Curriculum
Category URL: https://codehs.com/blog/category/hsms-curriculum
URL: https://codehs.com/blog/how-to-write-a-unit-test-problem-on-codehs-9e82aa70dfd8

* * *

### How to Write a Unit Test Problem on CodeHS

Writing a unit test problem with _CodeHS Create_ makes it really easy for you to create custom problems for your students and give them instant feedback.

Unit test problems allow you to easily test a function or method written by a student by just writing the solution and picking some test calls.

#### Step 1: Select a Unit Test in your desired programming language

First select Unit Test and the language you want the function or method to be in. Then click Create Activity.

![undefined](https://prod.superblogcdn.com/site_cuid_cm264m3an0084qegvyd7aetst/images/1wca5su2twnjfre0cnsgtw-1728981631015-compressed.png)

#### Step 2: Write the description students will see when they visit the problem

This will pop up as a description of the goal of the problem. You can write in the text in Markdown as well and see a preview.

![undefined](https://prod.superblogcdn.com/site_cuid_cm264m3an0084qegvyd7aetst/images/1z8pkrut9nkouhme8mw7erw-1728981633681-compressed.png)

#### Step 3: Write the starter code and solution code for the method

Here you need to write the method or function. At the top we wrote the empty method, then under solution code we write the solution for this method. Student’s can solve it in any way as long as they get the right outputs.

![undefined](https://prod.superblogcdn.com/site_cuid_cm264m3an0084qegvyd7aetst/images/1dae3q6m65v5s4tloyt9q-1728981636841-compressed.png)

#### Step 4: Write the test cases

Once you write your solution, we automatically detect the method name and signature. Then you can go and write as many test cases as you want.

![undefined](https://prod.superblogcdn.com/site_cuid_cm264m3an0084qegvyd7aetst/images/1kjlhuuibn1gkkjc5kn5e0a-1728981639814-compressed.png)

#### Step 5: Students Receive Instant Feedback on Your Problem

That’s it! Now when students are solving this problem they’ll get immediate feedback on how they performed on the test cases!

![undefined](https://prod.superblogcdn.com/site_cuid_cm264m3an0084qegvyd7aetst/images/1p6hrvswedvowvxialwu-lq-1728981642422-compressed.png)

As more teachers create problems, these will build up a shared repository of great coding challenges in the Problem Bank that you’ll be able to use in your class as well!

You can also watch this 2 minute screencast on how to create a problem.

Questions? Email hello@codehs.com!


---
This blog is powered by Superblog. Visit https://superblog.ai to know more.
---

