why my test launch the QuarkusTestResourceLifecycleManager without importing it ?

117 views
Skip to first unread message

Sébastien Dionne

unread,
Feb 3, 2021, 11:43:15 AM2/3/21
to Quarkus Development mailing list
I'm using Quarkus 1.10.5.Final

I have a junit like this
@QuarkusTest
class MachineHelperTest {

but why when the test starts it will execute classes that implements  QuarkusTestResourceLifecycleManager 

like 
public class KindClusterForQuarkusTest implements QuarkusTestResourceLifecycleManager {

it's a plain junit.. no injection, no cluster.. real plain junit.


but I have also other tests that are using TestResources like

@QuarkusTest
@QuarkusTestResource(TwinApiServiceDockerCompose.class)
@QuarkusTestResource(KindClusterForQuarkusTest.class)
public class MachineMainCodecControllerTestIT { 

it will work OK, because I expect to launch a cluster  +docker for thoses tests.

Georgios Andrianakis

unread,
Feb 3, 2021, 12:08:09 PM2/3/21
to Sébastien Dionne, Quarkus Development mailing list
On Wed, Feb 3, 2021 at 6:43 PM Sébastien Dionne <sebastie...@gmail.com> wrote:
I'm using Quarkus 1.10.5.Final

I have a junit like this
@QuarkusTest
class MachineHelperTest {

but why when the test starts it will execute classes that implements  QuarkusTestResourceLifecycleManager 

like 
public class KindClusterForQuarkusTest implements QuarkusTestResourceLifecycleManager {

it's a plain junit.. no injection, no cluster.. real plain junit.


These classes are considered "global", so anywhere you place them, they will be utilized.
 

but I have also other tests that are using TestResources like

@QuarkusTest
@QuarkusTestResource(TwinApiServiceDockerCompose.class)
@QuarkusTestResource(KindClusterForQuarkusTest.class)
public class MachineMainCodecControllerTestIT { 

it will work OK, because I expect to launch a cluster  +docker for thoses tests.

--
You received this message because you are subscribed to the Google Groups "Quarkus Development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to quarkus-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/quarkus-dev/7cb36c8d-cfb7-4875-bf6d-21f6faaa537cn%40googlegroups.com.

Falko

unread,
Feb 3, 2021, 12:53:01 PM2/3/21
to Quarkus Development mailing list
So I had this (maybe stupid?) idea to enhance @QuarkusTestResource so that it can be added to `package-info.java`.
This would make it more clear that such resources/managers are executed for all tests in that package (and sub-packages), while retaining backward compatibility.

This _could_ then go as far as to log a warning when @QuarkusTestResource is placed on a class...

One downside I can see right away is the need for a separate file (and while it is not a bad idea to document packages this way every now and then, test packages usually don't need such documentation/files).
Message has been deleted

Sébastien Dionne

unread,
Feb 3, 2021, 3:24:44 PM2/3/21
to Quarkus Development mailing list
wierd.  my previous message was deleted :(  


I read the documentation about testing, and I found this remark : 

only the QuarkusTestResourceLifecycleManager classes enabled via the @QuarkusTestResource class annotation will be used for the tests using this profile (which is the same behavior as tests that don’t use a profile at all).

in my junit class, I don't use those annotation, so the classes that implements QuarkusTestResourceLifecycleManager  shouldn't have been used.

Sébastien Dionne

unread,
Feb 4, 2021, 8:39:09 AM2/4/21
to Quarkus Development mailing list
I created a issue to track the information


my point is that @QuarkusTestResource should be used only when they are in a specific tests when the annotations are in that test.
Reply all
Reply to author
Forward
0 new messages