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 functionalityswing/src/test/java— tests for Swing UI components
Running tests
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
Writing good tests
Test one thing per method
Each test method should verify a single behavior. This makes failures easy to diagnose and keeps test names meaningful.
Use descriptive names
Name test methods so that the failure message explains exactly what is broken — for example,
testNoseConeVolumeWithZeroLength.Follow Arrange-Act-Assert
Structure your test body in three sections: set up the state, execute the code under test, then assert the outcome.
Mock external dependencies
Isolate the unit under test by mocking databases, file system access, or other external services.
Test edge cases and error conditions
Cover boundary values, null inputs, and exception paths — not just the happy path.
Code coverage
OpenRocket uses JaCoCo to track and enforce test coverage. Coverage verification runs automatically during JAR packaging.| Module | Coverage threshold |
|---|---|
core | 60% minimum |
swing | Disabled (0%) — limited test coverage |
Generating coverage reports
build/reports/jacoco/— aggregate reportcore/build/reports/jacoco/— core module reportswing/build/reports/jacoco/— Swing module report
Debugging
The most effective debugging tool is your IDE’s built-in debugger. Both IntelliJ IDEA and Eclipse offer full Java debugging support.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.
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.