-
Notifications
You must be signed in to change notification settings - Fork 36
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
Cannot use @InjectMock with mybatis Mapper interfaces #217
Comments
facing the same issue |
Workaround is to mock mapper using Mockito.mock(), but some of my tests fail because mock returns null value |
@abondar24 Nice catch! and is it possible to share your test? And I think it could be very helpful for other people. Also the contribution is welcome! |
@zhfeng here is a test: https://github.com/abondar24/QuarkusDemo/blob/master/src/test/java/org/abondar/experimental/quarkusdemo/service/PersonServiceTest.java |
I'm facing the same issue. Unfortunately the Mockito.mock() and MockitoAnnotations.openMocks(this) does not work! The mocks are created in the test class, but they are not injected into the test-subject (the object @Inject'ed into the test-class). The issue we are facing is described in this bug: quarkusio/quarkus#40152 One fix is changing the MapperProxies to be @ApplicationScoped and not @singleton. |
I'm trying to mock a mybatis Mapper interface for unit test.
The mapper interface is like :
unit test:
Running this test will fail with :
As https://quarkus.io/guides/getting-started-testing#further-simplification-with-injectmock said:
I tried
convertScopes = true
:but the test still failed with the same error.
The text was updated successfully, but these errors were encountered: