All Questions
6 questions
0
votes
1
answer
1k
views
Mock a bean with 10 methods when I only use one?
I face some situations similar to the following simplified one:
@Component class ServiceOne {
@Autowired ServiceTwo two;
void act() {
...
two.a();
...
}
}
@...
6
votes
1
answer
16k
views
Should I mock ObjectMapper in my unit tests?
I have different services in a spring application that have a dependency on Jackson ObjectMapper, the unit tests rely on @InjectMocks to inject all the various dependencies to the class that is under ...
3
votes
4
answers
1k
views
How do I deal with the fact that I am forced to make helper functions public for testing purposes?
I've encountered several scenarios that require me to mock certain helper methods because they call outside resources. As a result, I'm forced to convert all my helper methods from private into public....
3
votes
1
answer
4k
views
What's the correct way to test code which performs IO?
Is there a nice way to test code which performs IO? In Java in particular, if you go the Mock route, you need to wrap most of the native APIs in your own mockable classes, something like:
public ...
1
vote
1
answer
873
views
Using Mockito.reset
I've just read a lot of arguments against using Mockito.reset and can't make much sense of it. Put differently, I agree in general, but there's always a case which looks like using reset is useful or ...
5
votes
3
answers
2k
views
how and should I 'unit test' an entire package?
I'm still learning to be good about doing unit level testing, as I've always been a little sloppy about only doing functional testing in the past, so I want to double check I'm doing this 'right'.
I ...