Reputation: 11
I am trying to use JMockit- 1.45 to test spring based services. Strangely, I am unable to mock List objects. I have also noticed similar behavior for other non-mockable classes mostly from java.util.*
.
How can I achieve the below mentioned in Jmockit?
class ServiceA{
@Autowired
private List<SomeObj> list;
.......
}
Class ServiceATest{
@Injectable
private List<SomeObj> list;
@Tested
private ServiceA serviceA;
.............
}
I am getting below error
Caused by: java.lang.IllegalArgumentException: java.util.List is not mockable
Upvotes: 1
Views: 938
Reputation: 16390
Use @Tested
on the List
field, initializing it with the actual list to be injected.
Upvotes: 0