Skip to main content
Creating a JUnit Autograder

Learn how to use the JUnit framework with your custom coding exercises

Sara Jenis avatar
Written by Sara Jenis
Updated over 2 months ago
Banner: This is a free feature

As an alternative to the CodeHS Java autograders, you can build your own JUnit autograders to test student code. See our full documentation here.

Creating an Assignment with a JUnit Autograder

From the Create App

  1. Access the Create Assignments tool by clicking Create from the left menu.

    1. If you haven't done so yet, Create a Coding Exercise and choose one of the Java options.

    2. Add an assignment title, description, and any starter or solution code for the assignment.

    3. Save your changes, and close the popup window, and refresh the page.

  2. Click the three dots "..." next to an assignment you created and choose Edit.

  3. Scroll down to the bottom of the window and choose Custom Autograder Edit.

  4. Click the Add JUnit Autograder button. An autograder with example tests and comments will be added.

  5. Add your test to the JUnitExampleTests.java file and click Save Autograder Code.

Animated GIF showing how to access the JUnit Autograder edit window on CodeHS

From the Assignments App

  1. Click Assignments from the left menu.

  2. Choose the course where you'd like to add an assignment by clicking the dropdown menu in the upper left corner. If you've already created a Coding Exercise, skip down to step 7.

  3. Click the blue Add button in the upper right corner and choose Assignment.

  4. Add a title, choose which lesson and modules you would like to add the assignment to and select Create.

  5. Select Coding Exercise, then choose which program type you would like to create, such as Java(main).

  6. Add an assignment description and any starter code for the assignment. Once finished, save your changes and exit out of the editing window.

  7. Click Edit next to the assignment you created.

  8. Scroll down to the bottom of the window and choose Custom Autograder Edit.

  9. Click the Add JUnit Autograder button. An autograder with example tests and comments will be added.

  10. Add your test to the JUnitExampleTests.java file and click Save Autograder Code.

Animated GIF demonstrating how to access the JUnit Autograder editing window from the Assignments tool on CodeHS

Creating a JUnit Autograder Demo


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

Did this answer your question?