jmockit测试例子

时间:2013-12-06 01:04:50
【文件属性】:

文件名称:jmockit测试例子

文件大小:169KB

文件格式:MHT

更新时间:2013-12-06 01:04:50

jmockit_hwh

Mockup always comes to us when we try to break system dependency. The conventional mockup frameworks only allowed us to mock instance methods. So the static methods usually become to the death of testability. Of course, we still have some way to make it become testable. 1. If the static methods invoke only happens in few classes, we could create an adaptor to isolate them. The implementation of adaptor is just simply delegation. 2. Unfortunately, sometimes your legacy system maybe full of static methods calling, they scatter in different tiers. It indeed a bad smell, but before you refactor them, you may need to make them testable firstly. Now, jmockit comes to us. "Tests can easily be written that will mock final classes, static methods, constructors, and so on. There are no limitations."


网友评论

  • 得为这个资源点个赞,有兴趣的朋友可以下载看看
  • 不再使用jmockit了,感觉不如EasyMock+PowerMock顺手