Skip to content

feat(spring): @DataStormTest test slice#230

Merged
zantvoort merged 1 commit into
mainfrom
feat/data-storm-test
Jul 11, 2026
Merged

feat(spring): @DataStormTest test slice#230
zantvoort merged 1 commit into
mainfrom
feat/data-storm-test

Conversation

@zantvoort

@zantvoort zantvoort commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

Spring users test Storm code with a full @SpringBootTest or with Storm's own @StormTest, which bypasses the Spring context entirely. What was missing is the slice test Spring users reach for first, like @DataJpaTest or @JooqTest.

Fixes #200

What's included

  • New storm-spring-boot-test-autoconfigure module (mirroring Boot's own layout, where @DataJpaTest lives in spring-boot-test-autoconfigure) with @DataStormTest: starts only the DataSource, Storm's auto-configuration (template, repository scanning, transaction integration, schema validation, exception translation, observations), SQL initialization, and Flyway or Liquibase when present. Regular @Component/@Service/@Controller beans stay out via a type exclude filter honoring includeFilters/excludeFilters/useDefaultFilters; a bootstrapper applies the annotation's properties attribute.
  • Transaction-per-test with rollback: the slice is meta-annotated @Transactional and includes the transaction bridge, so Storm repository writes join the Spring-managed test transaction and roll back after each test.
  • Embedded database by default (Spring Boot 3), Testcontainers as opt-out: the slice imports the test-database auto-configuration, replacing the application's DataSource with an embedded database; spring.test.database.replace=none runs against the configured one, such as a Testcontainers-managed database via @ServiceConnection. On Spring Boot 4 the replacement activates when spring-boot-jdbc-test-autoconfigure is present.
  • One module serves both starters: the slice pulls in the starters' identically named auto-configuration classes (the Bring the Java Spring modules to transaction parity with Kotlin #202 alignment), with Boot 3 and Boot 4 platform entries listed as optional: imports, and the type exclusion registered through a context customizer built on FQCN-stable core classes rather than @TypeExcludeFilters, which Spring Boot 4 relocated. The module has no compile dependency on Storm; one artifact serves Boot 3 and Boot 4 (verified against Spring Boot 4.1 applications).

Relationship to @stormtest

@StormTest (storm-test) remains the fast, framework-free option for query-level tests; @DataStormTest covers what production Spring code sees — injected repository beans, translated exceptions, Spring-managed transactions, storm.* configuration. The docs cross-reference both with a rule of thumb.

Verification

  • Full reactor green (13,724 tests across 26 modules).
  • Module tests against the Java starter: repository scanning and injection, component exclusion, active test transaction, rollback between ordered tests, exception translation active inside the slice, properties attribute applied.
  • Kotlin starter smoke suite: the same annotation resolves the Kotlin starter's auto-configurations, repositories bind through the Kotlin adapter, and writes roll back per test.

Docs: "Testing with @DataStormTest" section in spring-integration.md with H2 and Testcontainers examples; cross-links between testing.md and the slice section; CHANGELOG entry. Module registered in the reactor and the BOM.

@zantvoort zantvoort force-pushed the feat/data-storm-test branch from 720e0f0 to 4cc80fd Compare July 11, 2026 20:05
Spring users test Storm code with a full @SpringBootTest or with Storm's
own @stormtest, which bypasses the Spring context entirely. What was
missing is the slice test Spring users reach for first, like
@DataJpaTest or @JooqTest.

- New storm-spring-boot-test-autoconfigure module with @DataStormTest:
  starts only the DataSource, Storm's auto-configuration (template,
  repository scanning, transaction integration, schema validation,
  exception translation, observations), SQL initialization, and Flyway
  or Liquibase when present. Regular components stay out via a type
  exclude filter honoring includeFilters/excludeFilters; a bootstrapper
  applies the annotation's properties attribute.
- Each test method runs in a Spring-managed transaction rolled back
  afterwards; Storm operations join it through the transaction bridge.
- By default an embedded database replaces the application's
  DataSource; @AutoConfigureTestDatabase(replace = NONE) runs against
  the configured database, such as a Testcontainers-managed one via
  @Serviceconnection.
- One module serves both starters: the slice pulls in the starters'
  identically named auto-configuration classes, with Boot 3 and Boot 4
  platform entries listed as optional imports. The module has no
  compile dependency on Storm.

Fixes #200
@zantvoort zantvoort force-pushed the feat/data-storm-test branch from 4cc80fd to ee350c5 Compare July 11, 2026 20:22
@zantvoort zantvoort merged commit 7cf88b0 into main Jul 11, 2026
7 checks passed
@zantvoort zantvoort deleted the feat/data-storm-test branch July 11, 2026 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a @DataStormTest test slice

1 participant