JUnit Testing Framework

Codio provides a simple way to test Java in your project using Junit framework. To use JUnit, your project requires Java. Use one of the following methods to make sure your project uses Java:

  • Use the Java8 Stack.

  • Manually install Java on your box.

  • Install Java from Tools > Install Software. See Install Software Packages for more information.

Configure JUnit

To configure to use JUnit for Java testing, follow these steps:

  1. Click Tools on the menu bar and choose JUnit. You can also use the shortcut Shift+Alt+J.

    JUnit Settings
  2. Complete the fields on the JUnit Settings page:

    • JUnit version - Select the version from the drop-down list.

    • Source path - Location of the source code.

    • Test source path - Location of the test cases source folder.

    • Library path - Path to any libraries used by the project.

    • Working directory - Path where the compiled code should execute.

    • Add test case - Specify the paths to a file with JUnit tests or drag and drop the file into the JUnit field.


  • All paths are relative to the root (/home/codio/workspace or ~/workspace) of the assignment/project.

  • If using multiple cases in an assignment/project, the files for each should all be in separate folders for them to work independently of each other. This applies to student code files as well as the code used for the cases.

  • All code files Source path will be compiled. Files that fail to compile successfully will cause the tests to fail, even if they are not used.

Timeout settings

The default timeout for JUnit execution is 30 seconds. You can change the timeout and default hotkey in User Preferences or Project Preferences. To ensure that the same settings apply to all students using the same project, we recommend changing the timeout and hotkey in Project Preferences.

JUnit Preferences

Execute JUnit Test

You execute the tests from the JUnits Execution page (Tools > JUnit > Junit Executions). Once completed, the results are shown on the page.

JUnit Execute

If you publish your project as a unit to a class, the JUnit configurations you set up are included in the unit for students.