Este contenido no está disponible en el idioma seleccionado.
Chapter 6. Applying interceptors to tests
Quarkus tests are full CDI beans, so you can apply CDI interceptors as you would normally. For example, if you want a test method to run within the context of a transaction, you can apply the @Transactional annotation to the method. You can also create your own test stereotypes.
Procedure
Add the
quarkus-narayana-jtadependency to yourpom.xmlfile:<dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-narayana-jta</artifactId> </dependency><dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-narayana-jta</artifactId> </dependency>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Make sure the
TransactionalQuarkusTest.javaincludes the following import statements:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the
@TransactionalQuarkusTestannotation:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Apply this annotation to a test class where it will behave as if you applied both the
@QuarkusTestand@Transactionalannotations:Copy to Clipboard Copied! Toggle word wrap Toggle overflow This is a simple test that evaluates the greeting service directly without using HTTP.