Only attempt mock reset on instantiated singletons
Update ResetMocksTestExecutionListener to only attempt a mock reset when a singleton has actually been created. Fixes gh-5870
This commit is contained in:
@@ -26,6 +26,7 @@ import org.springframework.boot.test.mock.mockito.example.ExampleService;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -80,6 +81,13 @@ public class ResetMocksTestExecutionListenerTests {
|
||||
return mock(ExampleService.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Lazy
|
||||
public ExampleService fail() {
|
||||
// gh-5870
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user