New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Annotation for resetting context, threads and containers for integration tests #26818
Comments
/cc @geoand |
Which kinds of Quarkus test are you talking about specifically? |
Im talking about integration tests, so tests which are annotated with @QuarkusTest and where the whole context is spinned up. Sometimes we even spin up external services for more complete system tests. |
You can already do this manually by using a test profile: https://quarkus.io/guides/getting-started-testing#testing_different_profiles |
As far as I have understood this we need to write a profile for each @Quarkustest to restart the context. Does this mean that we have to write 1000 profiles when we have 1000 @QuarkusTest? Or am I getting this wrong? |
Indeed you would have to |
I think it would be nice if we could implement an addition to the @QuarkusTest annotation like @QuarkusTest(ResetStrategy.AfterEach) so the context would be restartet after each test. Then you could have AfterEach, AfterClass or None something like in JUnit. |
Thanks for the feedback. We'll definitely consider it |
I would like something like this too. Something like Spring's annotation |
There is no such thing a context restart in Quarkus. If we do something, it will be the exact same thing that we do when switching test profiles |
Ah, fair enough. In the meantime, I've already solved my issue. It was the bug that was just solved with |
Yeah, that was an oversight on our part |
Is this primarily about cleaning up data from a previous test? If you have many tests, fully restarting everything after each test will be no fun in terms of runtime! |
Yeah, it will be very very slow... |
Yes its primarly about cleaning data and it would be very slow if we would do that for every single test but it would still be nice if it could work like in spring. Even if it could be very slow if you use it at all tests. I think it is cleaner and safer than trying to clear old data by myself especially at massive multithreading with multiple async processes. |
This is a bit late reply, I actually made a similar annotation in my quarkus project using CDI bean injection, so, it will be nice addition for integration tests. |
Can you show what that looks like @deathwaiting? |
springs annotation targets both classes and methods, in the case of annotating a test class, it will run for each test method inside it |
Great, thanks |
Is there already something similar? I have the feeling that the my beans in my container are getting messed up with @InjectMock and @InjectSpy and would like to test the behaviour if I could reset the application including all beans before a test |
That should not be the case. If they are, we'll need a sample application that shows this problem so we can address it |
Hi guys, do you plan to work on this? |
It's in the backlog, but it's not high priority |
Description
Before I switched to Quarkus, I used Spring and Spring has a feature which I really miss in Quarkus. Dont get me wrong I love working with Quarkus.
But Spring has the @DirtiesContext annotation and its very valuable in integration tests. I know that Quarkus has @TestTransaction but this seems not to work all the time. It worked fine until we integrated our database which also uses transactions and at this point @TestTransaction stopped working. In Spring this was never a problem but in Quarkus we have now the problem that our integration tests somehow depend on each other because @TestTransaction does not reset the context correctly.
Hopefully I explained the problem well, so maybe we could implement @DirtiesContext for Quarkus which restarts the context and restarts all dev-services.
Implementation ideas
Ideally we would implement a @DirtiesContext annotation which restarts the context, kills all active threads - so every thread which was started gets killed and does not effect the next test - and restarts all containers which were started by dev-services or Testcontainers.
The text was updated successfully, but these errors were encountered: