class Testing{
@Autowired
ClassA classa;
public void test(){
MyService service = classa.someMethod();
service.getID(); //service is always null on this line
}
}
ClassA {
public MyService someMethod(){
return Myservice.builder().id(1l).build();
}
}
import lombok.Builder;
import lombok.Getter;
@Builder
@Getter
public class MyService {
private Long id;
private Long externalId;
}
试图模仿“myservice服务”,它总是空的。我们怎么嘲笑它?
myservice是一个builder类,@builder来自import lombok.builder;包裹
2条答案
按热度按时间ds97pgxw1#
pod7payv2#
使用junit4+mockito