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 a week ago

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

To create an assignment with a JUnit Autograder:

From the Create App:

  1. In the Assignments tool, click on the green Create New Assignment on the top right corner.

  2. Choose Coding Exercise and then choose which program type you would like to create (i.e. Java(main)).

  3. Add an assignment title, description, and any starter code for the assignment. Once finished, save the program and exit out of the editing modal.

  4. Click the three dots next to the assignment you just made, and click Edit.

  5. In the modal that pops up, choose Advanced Settings in the lower left corner.

  6. Navigate to the Autograders tab and click Add JUnit. An autograder with example tests and comments will be added.

  7. Add your test to the JUnitExampleTests.java file and click Save!

    Gif demonstrating how to create a custom coding exercise following the steps detailed above.

From the Assignments App:

  1. Choose the course you'd like to add an assignment for by clicking on the dropdown menu in the upper left corner.

  2. Then, click the blue Add button in the upper right corner and choose Assignment.

  3. Add an assignment title and choose which lesson and modules you would like to add the assignment to and choose Create.

  4. Choose Coding Exercise and then choose which program type you would like to create (i.e. Java(main)).

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

  6. Click Edit next to the assignment you just made.

  7. In the modal that pops up, choose Advanced Settings in the lower left corner.

  8. Navigate to the Autograders tab and click Add JUnit. An autograder with example tests and comments will be added.

  9. Add your test to the JUnitExampleTests.java file and click Save!

Gif demonstrating how to create a Java coding exercise and add a custom autograder to it by following the steps above.

Creating JUnit Autograder Demo


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

Did this answer your question?