- 
                Notifications
    You must be signed in to change notification settings 
- Fork 38.8k
Closed as not planned
Closed as not planned
Copy link
Labels
in: testIssues in the test moduleIssues in the test modulestatus: invalidAn issue that we don't feel is validAn issue that we don't feel is valid
Description
I expected @MockitoBean to also be injected into the Spring Context as @MockBean did.
Minimal reproducible project: https://github.com/Sax388/mockito-bean-failing-when-mock-bean-does-not
When using
@MockitoBean private TokenService tokenService;in https://github.com/Sax388/mockito-bean-failing-when-mock-bean-does-not/blob/c75c41eecb69080ea66292c07930b419de03a253/src/test/java/com/example/demo/cucumber/steps/RequestHelper.java#L24
then the test fails with
Cannot invoke "com.example.demo.TokenService.getTenantName()" because "this.tokenService" is null
java.lang.NullPointerException: Cannot invoke "com.example.demo.TokenService.getTenantName()" because "this.tokenService" is null
	at com.example.demo.cucumber.steps.RequestHelper.adminRequest(RequestHelper.java:27)
	at com.example.demo.cucumber.steps.TestSteps.makeTestRequest(TestSteps.java:16)
	at ✽.I make a test request(classpath:features/test.feature:4)
When using
@MockBean private TokenService tokenService;the test passes.
Metadata
Metadata
Assignees
Labels
in: testIssues in the test moduleIssues in the test modulestatus: invalidAn issue that we don't feel is validAn issue that we don't feel is valid