|
From: Owen R. <OR...@th...> - 2004-03-23 08:02:20
|
skizz and i have just checked in a new class called MockContainer. MockContainer springs from our observations about doing mock-driven development with constructor dependency injection (http://www.martinfowler.com/articles/injection.html). the basic idea is that you can use the MockContainer to instantiate your class-under-test and it will go and create and plug in your mocks for you a la picocontainer (http://picocontainer.org/). managing multiple mocks for a single class-under-test and ensuring that they are all verified can be a bit of pain. it is very easy to forget to verify a particular mock, and you have all of these mock members kicking around in your test case. enter MockContainer which manages all of this for you by dynamically determining the dependencies expected by your class-under-test. MockContainer uses reflection to automatically generate mocks for every constructor argument in the class-under-test. you can then ask the MockContainer for an instance of the class-under-test and it will create it by passing in the requisite mocks. calling Verify on the MockContainer will ensure that Verify is called on each of the created mocks. try it out and let us know what you think. i have also included a patch submitted by Jie Wang and Levi Khatskevitch. they fixed a problem with SetupResult where it wasn't properly verifying the return type of methods inherited from an interface <snip from="Jie's email"> What happens is when an interface inherits from another parent interface, the methods which belong to parent interface won't be returned through Type.GetMethod method. We have to track its parent path to find the return type. </snip> lastly, i have updated the loginfo in CVSROOT to use the centralised version of syncmail. the local copy in CVSROOT was blowing up due to some security changes made by sourceforge. commitinfo emails should now be coming out on the nmock mailing list again. cheers, owen. --- R. Owen Rogers ThoughtWorks Technologies (India) Pvt Ltd. ThoughtWorks - Deliver with passion! ThoughtWorks is always looking for talented people who are passionate about technology. To find out more about a career at ThoughtWorks go to http://www.thoughtworks.com/career/. |