Say we do the so-called interface test is really nondescript ah, the test is controller layer, that is called interface wood?!!! But the eldest brother said is the interface test, then interface it!
Since I took over to write this interface test soon, a lot of people, including a better relationship with the architect told me that writing this is very troublesome Ah, the code is messy, you have to mock a heap.
Now that you have jumped in, swim for a while. In order to mock, it is a way to do, from the general mock tool Mockito, to the reflection of Java, and finally found a powerful tool--powermockito he actually can mock private methods. Although, at last, the boss said that private methods should not be mock, well, then I can always record, perhaps later will be used. Here is an example:
Doshowchildrens private method for simulating Threadcontroller
Val postcountof24hourmap= new Hashmap[string, Int] ()
Postcountof24hourmap.put ("1009", 26)
Postcountof24hourmap.put ("1010", 90)
Mav.addobject ("Postcountof24hourmap", Postcountof24hourmap)
var childrensmap =new Hashmap[string,forumdynamicinfo] ()
val forumdynamicinfo:forumdynamicinfo = new Forumdynamicinfo
Forumdynamicinfo.setrsscount (50)//Set number of followers
childrensmap.put ("1010", null)
childrensmap.put ("1009", Forumdynamicinfo)
mav.addobject (" Childrensmap ", Childrensmap)
var childrens = new Linkedlist[forum] ()
Val childforum = new Forum
Childforum.setfid (1009)
Childforum.setname ("Test section")
Childforum.setdescription ("Record Your Mood")
Childforum.seticon ("Http://www.icon.com/icon.jpg")
Childforum.seticonurl ("http://www.19lou.com")
Val Moderator = new Moderator
Moderator.setusername ("moderator")
Childforum.setmoderatorlist (List (moderator))
Childrens.add (Childforum)
Mav.addobject ("childrens", childrens)
Powermockito.doreturn (MAV). When (Threadcontrollerspy, "Doshowchildrens", Mav,forum);
Http://blog.sina.com.cn/s/blog_6176c38201014dg1.html
Use Powermockito to mock private methods (GO)