Presentation is loading. Please wait.

Presentation is loading. Please wait.

A Pecha Kucha by Curt Gratz.  Husband  Dad  Coach  Youth leader  Co-owner of Computer Know How  Member of TEAM ColdBox.

Similar presentations


Presentation on theme: "A Pecha Kucha by Curt Gratz.  Husband  Dad  Coach  Youth leader  Co-owner of Computer Know How  Member of TEAM ColdBox."— Presentation transcript:

1 A Pecha Kucha by Curt Gratz

2  Husband  Dad  Coach  Youth leader  Co-owner of Computer Know How  Member of TEAM ColdBox

3

4  Because your immature  Because the functionality your unit testing is HARD  Because the functionality your trying to build relies on something that isn’t built yet  Because you want to control the expectations

5  When it’s appropriate… When using TDD (Test Driven Development) When your early in the development cycle When your agile and you need results from functionality not built yet You're mocking me, aren't you?

6  Prior  Planning  Prevents  Piss  Poor  Performance

7  Lots of techniques  Develop your mocking framework  MockBox  Enough already, on to some code examples…

8  Inside a ColdBox application  Outside a Coldbox application

9  In my handler I would do something like this to “Mock” my data.  And then my view would use that information.

10  In my handler, I want my fully implemented code to be this  And my view would still be the same

11  Mock right in the function Still have to touch the function  Create an object to do mocks Good technique outside ColdBox In ColdBox, it could be an interceptor object  preHandler() This is my preferred technique  So, let’s mock our example already…

12  rc.userID Let it come from a form or URL Set it in the preHandler() No need to mock, as it’s a simple value and will be in our fully implemented “example”

13  UserService  model.User.UserService

14  clearMethods? If true, all methods in the target mock object will be removed You can then mock only the methods that you want to mock  callLogging? Add method call logging for all mocked methods only Get statistics on mocked calls, effects $results

15  UserService.get()  model.User.User

16  $ ????? Shortcut for mockMethod ○ This is the method that you will call upon in order to mock a method's behavior and return results ○ Can even throw an exception (throwException)

17  user.getName()  user.getVisitCount()

18  $results ??? Shortcut for mockResults ○ Comma delimited list ○ Cycles through list each time the mocked method is called ○ I.e. (5,6,7,5,6,7….)

19  In my handler I can have my fully implemented code to be this…  And my view would still look like this…

20  More information about MockBox http://www.coldbox.org http://wiki.coldbox.org/wiki/MockBox.cfm http://blog.coldbox.org/archives.cfm/category/mockbox Get MockBox @ http://www.coldbox.org/downloadhttp://www.coldbox.org/download  Contact information E-mail: gratzc@compknowhow.comgratzc@compknowhow.com Blog: http://www.coldbox.org/bloghttp://www.coldbox.org/blog Twitter: gratzc MSN IM: gratzc@compknowhow.comgratzc@compknowhow.com


Download ppt "A Pecha Kucha by Curt Gratz.  Husband  Dad  Coach  Youth leader  Co-owner of Computer Know How  Member of TEAM ColdBox."

Similar presentations


Ads by Google