文件名称: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."