Questions tagged [spybean]
5 questions
1
vote
0 answers
Programmatically create a Mockito SpyBean of a given Class
My abstract test needs to create a SpyBean of a defined class within the concrete implementation and I do not want the implementation or the "user" to have to add the @SpyBean annotation.
How can I programmatically create a SpyBean of a given Class…

Marian Klühspies
- 15,824
- 16
- 93
- 136
0
votes
1 answer
is it the moment to use @SpyBean?
i have a bean like this one
@Service
public class SpringParent {
@Resource
SpringChild sc;
public String giveChild() {
return sc.giveChild();
}
}
and a test class like this one..
public class InjectMock3 {
@Spy
…

work-in-progress
- 21
- 1
0
votes
0 answers
@SpyBean not support circular bean
springboot version:2.4.13
spring-boot-starter-test version: 2.4.13
question
when use @SpyBean ,it not support circular bean
eg:
public class A {
@Autowired
private B b;
public String getName() {
return A.class.getName();
…
0
votes
1 answer
NotAMockException when trying to mock a method on a SpyBean of Environment
In an integration test (@SpringBootTest) class I declare a spyBean:
@SpyBean
private Environment environment;
In a test I try to mock one method:
doReturn(true).when(environment).acceptsProfiles(Profiles.of("prod"));
However, I get the following…

Greg
- 1,227
- 5
- 23
- 52
0
votes
0 answers
ServiceActivator invoked twice when only one message is published
I have the following JUnit test that is basically an example of a production test.
@Autowired
private MessageChannel messageChannel;
@SpyBean
@Autowired
private Handler handler;
@Test
public void testPublishing() {
SomeEvent event = new…

reka18
- 7,440
- 5
- 16
- 37