Blog

Luis Majano

June 09, 2009

Spread the word


Share your thoughts

I am proud to announce another addition to our ColdBox Platform: MockBox.  MockBox is a companion package to the ColdBox Platform that will give you advanced mocking/stubing capabilities; hence a Mocking Framework. Not only does it integrate into the ColdBox unit testing framework powered by MXUnit, but it can also be used as a standalone mocking/stubing framework for ANY type of stubing/mocking you would like to do outside of ColdBox application, in any ColdFusion application.  First of all, I want to thank Brian Kotek for his inspiration, and the MXUnit "locos", Marc Esher and Billy Shelton.  These guys are excellent and their contributions to the ColdFusion Community have changed the way I develop.  I had the privilege of talking to them at CF.Objective this year and discussing mocking and testing, so thank you so much guys for all the ideas and for the hard work, you guys truly rock!!

MockBox version 1.0 Beta is now on SVN and can be downloaded by downloading the ColdBox Nightly Build found in our download area.  Also, in tradition of always bringing you the best documentation and samples, we have our guide ready for consumption.  The documentation goes over every feature of MockBox, samples and how to use it.  So before I go over some of the features of MockBox, let me give a brief introduction of what a Mock is.

"A mock object is an object that takes the place of a 'real' object in such a way that makes testing easier and more meaningful, or in some cases, possible at all". by Scott Bain (Emergent Design - The Evolutionary Nature of Professional Software Development) http://www.netobjectives.com/emergent-design-evolutionary-nature-professional-software-development
That is a great definition by Scott Bain, direct and to the point.  So what are the features of MockBox:

The approach that we take with the MockBox is a dynamic and minimalistic approach. Why dynamic? Well, because we dynamically transform target objects into a mock form at runtime. The API for the mocking factory is very easy to use and provides to you a very simplistic approach to mocking. So what can the mock factory do for me?

  • Create mock objects for you and keep their methods intact (Does not wipe methods, so you can do method spys, or mock helper methods).
  • Create mock objects and wipe out their methods (Wipes out the entire set of methods).
  • Create stub objects for objects that don't even exist yet. So you can build to interfaces and later build dependencies.
  • Decorate instantiated objects with mocking capabilities (So you can mock targeted methods and properties; spys)
  • Mock internal object properties (In any scope)
  • Have a method return 1 or more expected results.
  • State-Machine Results. Have a method recycle the results as it is called consecutively. So if you have a method returning two results and you call the method 4 times, the results will be recycled: 1,2,1,2
  • Method call counter, so you can keep track of how many times a method has been called.
  • Method arguments call logging, so you can keep track of method calls and their arguments as they are called.
  • Ability to mock private/package methods
  • Ability to mock exceptions from methods or make a method throw a controlled exception.
  • Ability to change the return type of methods or preserve their signature.
  • Ability to make methods return results according to argument signatures
So there you go, this is MockBox in a nutshell.  So get to it, download it now, read the guide and enjoy your testing via MXUnit.

Add Your Comment

Recent Entries

Ortus Black Friday Deals are here!

Ortus Black Friday Deals are here!

Make 2023, the year you finally start modernizing your CFML projects with our Black Friday deals!

Don't waste any more time trying to find solutions, we got everything you need to rock your projects and learn new skills that will save you time and money while delivering a quality service. 

From Nov 25th to Dec 1st

Maria Jose Herrera
Maria Jose Herrera
November 25, 2022
Call For Speakers Open for Into The Box 2023

Call For Speakers Open for Into The Box 2023

We are very excited that the Into The Box conference is coming back to the Houston area and FINALLY on our normal schedule of May of 2023. Registration is now officially open and call for papers is now open as well. We are also extremely excited that this will be our 10 year anniversary for the Into The Box Conference. So we will defintely go all out!

  • Full 2-day conference with over 30 different technology topics
  • An additional full day of hands-on training available for a veritable 3 days of awesomeness
  • A warm and sunny city of The Woodlands, Texas
  • When: May 17-19 of 2023
  • Modernize Your Skillz
  • Party with our live Mariachi Band!

Luis Majano
Luis Majano
November 11, 2022
New Patreon Perk: Ortus Software Craftsmanship Book Club

New Patreon Perk: Ortus Software Craftsmanship Book Club

What is the Software Craftsmanship Book Club?

Its a place for CFML Community members can get together, discuss and debate the thoughts, ideas, best practices outlined by a series of books focusing on increasing Software Developers efficiency, productivity and pride. It will be relaxed but educational environment, where we can learn from each other, and grow as a community.

 

Ortus Software Craftsmanship Book Club

Maria Jose Herrera
Maria Jose Herrera
November 09, 2022