spring-projects / spring-projects/spring-modulith

Add support of @Sql in tests of @ApplicationModuleListener

Open
#1,443 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

in: test support meta: waiting for feedback
Dominant language
Java
Stars
1.2k
Forks
222
PR merge metrics
No merged PRs in 30d

Description

Could you please add support of sql scripts in tests of module listeners (org.springframework.modulith.events.ApplicationModuleListener)?

I. e. this:

    @Test
    @Sql("classpath:sql/some-inserts.sql", "classpath:sql/file-abcd.sql")

do inserts rows in one transaction, but this:

    @ApplicationModuleListener
    fun on(event: SomeCoolStuffHappened) {

creates a new txn and does not see inserts from @Sql. W/o this support one need to mock a bunch of stuff.

Thanks in advance!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how @ApplicationModuleListener test execution manages transactions and how Spring's @Sql scripts are applied. Reproduce the example with inserts from both SQL files, then add a regression test showing that the listener's new transaction can see those rows. Done means @Sql-backed listener tests work without mocking the involved components.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot, sql
Domain
backend, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.