Adapt to Mockito support in the Test Context Framework

This commit updates MockitoTestExecutionListener to not handle mocks
as this is already done in the listener provided by the core framework,
and registration can only happen once.

Integration tests have been left as-is to validate that the presence
of both listeners doesn't have an unwanted side effect.

See gh-41177
This commit is contained in:
Stéphane Nicoll
2024-03-12 08:26:23 +01:00
committed by Andy Wilkinson
parent 2053e13c09
commit 305bfb1641
2 changed files with 2 additions and 76 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,14 +53,6 @@ class MockitoTestExecutionListenerTests {
@Mock
private MockitoPostProcessor postProcessor;
@Test
void prepareTestInstanceShouldInitMockitoAnnotations() throws Exception {
WithMockitoAnnotations instance = new WithMockitoAnnotations();
this.listener.prepareTestInstance(mockTestContext(instance));
assertThat(instance.mock).isNotNull();
assertThat(instance.captor).isNotNull();
}
@Test
void prepareTestInstanceShouldInjectMockBean() throws Exception {
given(this.applicationContext.getBean(MockitoPostProcessor.class)).willReturn(this.postProcessor);