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 page:

  1. Click Create New Assignment

  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 ... 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!

From the Assignments page:

  1. Click the blue Add button in the upper left corner and choose Assignment

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

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

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

  5. Click Edit next to the assignment you just made

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

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

  8. Add your test to the JUnitExampleTests.java file and click save!

Creating JUnit Autograder Demo

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

Did this answer your question?