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:
Phillip Webb
2016-05-16 13:03:04 -07:00
parent bcfa2e6676
commit 2fc86b2d5a
2 changed files with 15 additions and 4 deletions

View File

@@ -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();
}
}
}