-
Notifications
You must be signed in to change notification settings - Fork 1k
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
No backing TransactionOperations configured during test execution #10813
Comments
This was referenced May 10, 2024
Closing as per dstepanov's comment here: micronaut-projects/micronaut-data#2943 (comment) Opened a new improvement suggestion/discussion opener issue here. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected Behavior
Mocked repositories with methods annotated with
@Transactional
should work during testing. It doesn't matter if it is:@jakarta.transaction.Transactional
@io.micronaut.transaction.annotation.Transactional
The bug manifests itself with both annotations.
Actual Behaviour
Mocked repositories with methods annotated with
@Transactional
fail during testing witho.micronaut.context.exceptions.ConfigurationException: No backing TransactionOperations configured. Check your configuration and try again
.Bug test cases
@Transactional
2@Transactional
2@Transactional
2Steps To Reproduce
For your convenience, you can use the provided app example. But here are the steps anyway:
@Repository
).@Transactional
.@MicronautTest
), mock the Repository with Mockito and inject it into the ApplicationContext with@MockBean(Repository.class)
(to replace real Repository).io.micronaut.context.exceptions.ConfigurationException: No backing TransactionOperations configured. Check your configuration and try again
.If the
@Transactional
annotation is moved to a class level, the test will pass, but the Repository method will fail at runtime.If the example app isn't clear enough, please let me know and I'll add more information. Thanks.
Environment Information
Example Application
https://github.com/Nahuel92/Micronaut-test-bug
I added my findings to the README.md file.
Version
4.4.2
Footnotes
Tests mock repositories with
@MockBean(RepositoryClass.class)
. ↩It doesn't matter whether it's
@jakarta.transaction.Transactional
or
@io.micronaut.transaction.annotation.Transactional
. ↩ ↩2 ↩3The text was updated successfully, but these errors were encountered: