Blog

MockBox hits 1.0, get it now!

Luis Majano November 13, 2009

Spread the word

Luis Majano

November 13, 2009

Spread the word


Share your thoughts

MockBox has now reached a 1.0 release and can be downloaded now!  For those of you who don't know, MockBox is a companion framework to the ColdBox Platform that will give you advanced mocking/stubbing 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/stubbing framework for ANY type of stubing/mocking you would like to do outside of ColdBox applications, in any ColdFusion application. 

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 are amazing!

"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


MockBox Features
MockBox dynamically transforms target objects into mock/stub form at runtime. The API for the mocking factory is very easy to use and provides you a very simplistic approach to mocking.  We also use $() method notations to distinguish easily when you are using mocking capabilities on your code. 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 method signatures
  • 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, basically do property injections in any internal scope
  • 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.  This is a great way to find out what was the payload when calling a mocked method
  • Ability to mock results depending on the argument signatures sent to a mocked method with capabilities to even provide state-machine results
  • 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 at runtime, extra cool when using stubs that still have no defined signature
  • Ability to call a debugger method ($debug()) on mocked objects to retrieve extra debugging information about its mocking capabilities and its mocked calls
So get to it, download it now, read the guide and enjoy your testing via MXUnit.

Add Your Comment

Recent Entries

BoxLang 1.0.0 Beta 23 Launched

BoxLang 1.0.0 Beta 23 Launched

The latest release of BoxLang, Beta 23, marks a significant step forward in our journey to create the ultimate dynamic language for the JVM. Packed with powerful new features, important bug fixes, and thoughtful optimizations, this update is designed to make your development experience smoother, faster, and more reliable, especially after now starting to take 100s of comments and bug reports from our community.

Luis Majano
Luis Majano
November 23, 2024
TestBox Latest Updates and News!

TestBox Latest Updates and News!

We’re thrilled to have launched the new TestBox website and TestBox 6.0! If you haven’t had a chance to explore yet, visit TestBox to discover updated documentation, powerful resources, and features that make testing more efficient than ever.

Maria Jose Herrera
Maria Jose Herrera
November 21, 2024
Is Your ColdFusion Application Ready for the Future?

Is Your ColdFusion Application Ready for the Future?

In a rapidly evolving digital world, maintaining performance, security, and scalability for ColdFusion applications is more challenging than ever. Whether you're using Lucee or Adobe ColdFusion, legacy systems can become a bottleneck for growth, innovation, and user satisfaction. The need to future-proof your ColdFusion applications has never been more critical.

But where do you start?


The Hidden Costs of an Outdated ColdFusion Application

As you...

Cristobal Escobar
Cristobal Escobar
November 21, 2024