Skip to main content
This guide covers how to write, run, and debug tests in the OpenRocket codebase.

Unit testing

OpenRocket uses JUnit 5 (Jupiter) as its testing framework. Tests are organized in separate source trees from production code:
  • core/src/test/java — tests for core functionality
  • swing/src/test/java — tests for Swing UI components

Running tests

# Run all tests
./gradlew test

# Run tests for a specific module
./gradlew core:test
./gradlew swing:test

# Run a specific test class
./gradlew core:test --tests "info.openrocket.core.util.MathUtilTest"

Test structure

Tests in OpenRocket follow standard JUnit 5 conventions:
  • Test class names end with Test (for example, MathUtilTest)
  • Test methods are annotated with @Test
  • Many tests extend BaseTestCase, which provides common setup and utilities

Example test

package info.openrocket.core.util;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

public class ExampleTest extends BaseTestCase {

    @Test
    public void testSomeFeature() {
        // Arrange
        SomeClass instance = new SomeClass();

        // Act
        int result = instance.someMethod();

        // Assert
        assertEquals(42, result);
    }
}

Writing good tests

1

Test one thing per method

Each test method should verify a single behavior. This makes failures easy to diagnose and keeps test names meaningful.
2

Use descriptive names

Name test methods so that the failure message explains exactly what is broken — for example, testNoseConeVolumeWithZeroLength.
3

Follow Arrange-Act-Assert

Structure your test body in three sections: set up the state, execute the code under test, then assert the outcome.
4

Mock external dependencies

Isolate the unit under test by mocking databases, file system access, or other external services.
5

Test edge cases and error conditions

Cover boundary values, null inputs, and exception paths — not just the happy path.
6

Keep tests independent

Tests must not share mutable state. Each test should be able to run in any order and produce the same result.

Code coverage

OpenRocket uses JaCoCo to track and enforce test coverage. Coverage verification runs automatically during JAR packaging.
ModuleCoverage threshold
core60% minimum
swingDisabled (0%) — limited test coverage
If the core module falls below the 60% coverage threshold, JAR packaging will fail. Fix failing or missing tests before merging.

Generating coverage reports

# Generate an aggregate coverage report
./gradlew test jacocoRootReport

# Run the full build (includes coverage verification)
./gradlew build
After running, HTML reports are available at:
  • build/reports/jacoco/ — aggregate report
  • core/build/reports/jacoco/ — core module report
  • swing/build/reports/jacoco/ — Swing module report
A GitHub Actions workflow publishes coverage reports automatically on every push to the main branch, making it easy to track coverage trends over time.

Debugging

The most effective debugging tool is your IDE’s built-in debugger. Both IntelliJ IDEA and Eclipse offer full Java debugging support.
1

Set breakpoints

Click in the gutter next to the line you want to pause on. Conditional breakpoints let you pause only when a specific expression evaluates to true — useful in tight loops.
2

Run in debug mode

In IntelliJ IDEA, use the debug run configuration (the bug icon) instead of the normal run. In Eclipse, choose Run > Debug As > Java Application.
3

Inspect variables and call stack

When execution pauses at a breakpoint, inspect local variables in the Variables panel and navigate the call stack in the Debug panel. Use Evaluate Expression to run arbitrary code at the breakpoint.

Useful command-line debug flags

Several JVM system properties help during debugging. See Command line arguments for the full list. The most useful ones are:
# Enable extra debug tools in the UI
java -Dopenrocket.debug -jar OpenRocket.jar

# Show the debug file menu
java -Dopenrocket.debug.fileMenu -jar OpenRocket.jar

# Enable additional runtime safety checks
java -Dopenrocket.debug.safetycheck -jar OpenRocket.jar

Build docs developers (and LLMs) love