79515173

Date: 2025-03-17 16:33:53
Score: 1
Natty:
Report link

We have examples of what you are trying to do in the Quarkus Superheroes Sample application: https://github.com/quarkusio/quarkus-super-heroes

Specifically this service layer: https://github.com/quarkusio/quarkus-super-heroes/blob/main/rest-heroes/src/main/java/io/quarkus/sample/superheroes/hero/service/HeroService.java

And these tests: https://github.com/quarkusio/quarkus-super-heroes/blob/main/rest-heroes/src/test/java/io/quarkus/sample/superheroes/hero/service/HeroServiceTests.java

I think they key is https://github.com/quarkusio/quarkus-super-heroes/blob/main/rest-heroes/src/test/java/io/quarkus/sample/superheroes/hero/service/HeroServiceTests.java - Injecting a mock of your repository (or using PanacheMock if you are using the active record pattern.

If you are using the "real" database in your tests then yes you will need @TestReactiveTransaction, like in https://github.com/quarkusio/quarkus-super-heroes/blob/main/rest-heroes/src/test/java/io/quarkus/sample/superheroes/hero/repository/HeroRepositoryTests.java

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Eric