Chapter 4. Injection of CDI beans into tests
You can perform unit testing and test CDI beans directly. Quarkus enables you to inject CDI beans into your tests through the @Inject annotation. In fact, tests in Quarkus are full CDI beans so you can use the complete CDI functionality.
It is not possible to use injection with native tests.
Procedure
Create the
GreetingServiceTest.javafile with the following content:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The
GreetingServicebean will be injected into the test.