MXUnit 1.0.1 is now available!

Tuesday, July 29, 2008

MXUnit 1.0.1 is now available for download. This is a small patch release and includes:
  • var scope fixes
  • injectMethod functionality for simple mocking
That last one deserves some mention. Mock frameworks like Brian Kotek's ColdMock and Mike Steele's CFEasyMock are excellent tools for mocking collaborators. However, sometimes you want to spoof/override a function in your object under test for the purposes of testing some other function inside that same object. Say you have a function that hits the DB and you'd rather it not. Or you have a function that returns a query and you need to force it to return specific data rather than rely on the state of the database. If those functions are inside your object under test, a mock framework might not be much help here. That's why injectMethod was introduced... to solve the problem of mocking functions inside the object under test. A full write-up is available here. By way of history, this functionality came out of a previous post on mocking. I'll be providing a follow-up to that post, in the days to come, to show how that specific unit test changes as a result of injectMethod. Happy testing.

1 comment:

bill said...

Very nice! I love the fact you can quickly mock out a dependency in so few lines of code, AND without having to use another package.