Reputation: 85
I am working on my quarkus + kotlin application. Having class:
@ApplicationScoped
class ParrallerCronScheduler(private val someService: SomeService) : CronScheduler
When the application is running there is no problem, quarkus injects someService. However, running this tests class:
@QuarkusTest
@QuarkusTestResource(PostgresResource::class)
internal class CroneUpdateTest(private val someService: SomeService): BaseIntegrationTest()
makes quarkus throw:
When using constructor injection in a test, the only legal operation is to assign the constructor values to fields. Offending class is class com.tui.promotion_campaigns_service.services.impl.CroneUpdateTes
which forces to use this imo ugly thing in tests:
@Inject
lateinit var someService: SomeService
Why the first way of test implementation not working? Is it possible to make it work?
I tried
class ParrallerCronScheduler @Inject constructor(private val someService: SomeService) : CronScheduler
Upvotes: 4
Views: 456