Testing
Writing tests for database code can involve repetitive setup: creating a DataSource, running schema scripts, obtaining an ORMTemplate, and wiring everything together before the first assertion. Storm's test support module reduces this to a single annotation, letting you focus on the behavior you are testing rather than infrastructure.
The module provides two categories of functionality:
- JUnit 5 integration (
@StormTest) for automatic database setup, script execution, and parameter injection. - Statement capture (
SqlCapture) for recording and inspecting SQL statements generated during test execution. This component is framework-agnostic and works independently of JUnit.
Installation
Add storm-test as a test dependency.
Maven:
<dependency>
<groupId>st.orm</groupId>
<artifactId>storm-test</artifactId>
<scope>test</scope>
</dependency>
Gradle (Kotlin DSL):
testImplementation("st.orm:storm-test")
The module uses H2 as its default in-memory database. To use H2, add it as a test dependency if it is not already present:
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
JUnit 5 is Optional
JUnit 5 (junit-jupiter-api) is an optional dependency of storm-test. It is not pulled in transitively, so it does not appear on your classpath unless you add it yourself. Most projects already have JUnit Jupiter as a test dependency, in which case the @StormTest annotation and StormExtension are available automatically with no extra configuration.
If you only need SqlCapture and CapturedSql (for example, in a project that uses TestNG, or for development-time debugging outside of any test framework), storm-test works without JUnit on the classpath. The JUnit-specific classes simply remain unused.