Mocha 0.9 Released

Posted by James Mead Tue, 24 Jun 2008 19:14:00 GMT

There’s been quite a bit of work going on in Mocha over recent months, but a release is long overdue. The API is now pretty stable and so this release jumps from version 0.5 to 0.9. Much of the work has been refactoring Mocha’s internals to support new features and make the code more maintainable.

Before attempting the refactoring, extensive acceptance tests were added. One of the benefits of this is that it should now be easier to write new acceptance tests if you want to suggest new features or illustrate a bug ;-)

Here’s a quick summary of the changes in the release. I’ll try to post some code examples here in the near future.

Ordering constraints

Based on the JMock constraints with the same names…

Configurable warnings or errors

  • When a method on a non-public method is stubbed
  • When a method on a non-existent method is stubbed
  • When a method on a non-mock object is stubbed (partial mocking)
  • When a method is stubbed unnecessarily (i.e. the stubbed method is not called during the test)

See Configuration for more details.

Improved error messages

  • A more readable and complete list of unsatisfied expectations, satisfied expectations and state machines.
  • Display more sensible failure message for any_instance expectations.

Parameter matchers

  • New to this release: optionally (allows matching of optional parameters if available), yaml_equivalent (allows matching of YAML that represents the specified object), responds_with (tests the quack not the duck).
  • Nesting of matchers is now supported.

Syntax shortcut

An optional block can be passed into the Standalone#mock method. The block is evaluated in the context of the new mock instance and can be used as a shortcut to set up expectations.

Ruby & Rails compatibility

Tested with Ruby 1.8.4, 1.8.5, 1.8.6 & 1.9. All related bugs and warnings believed to be fixed.

Tested with Rails 1.2.3 & Rails 2.1.0.

Deprecation

There is no longer any need to have a “require ‘stubba’” statement in your code. A deprecation warning has been added to this effect, because the file will be removed in a future release.

Bug fixes

Posted in  | Tags , , , , , ,  | no comments

About Mock Objects

Posted by James Mead Mon, 02 Oct 2006 13:19:00 GMT

It’s good to see that Steve & Nat have resurrected mockobjects.com and are starting to publish new articles. They describe the site as…

About Mock Objects, a technique for improving the design of code within Test-Driven Development.

There are also some new developments in their JMock library.

Tags , , , , , , ,  | no comments

Google Test Automation & RailsConf Europe

Posted by James Mead Wed, 13 Sep 2006 09:55:00 GMT

Last week I was at Google’s inaugural London Test Automation Conference where I particularly enjoyed the talk by Adam Connors and Joe Walnes entitled “Does my button look big in this? Building Testable AJAX Applications”. It should be out on Google Video any day now (as are all the talks) and is well worth a look.

It was also good to hear from Nat Pryce and Steve Freeman about the new developments in JMock

Tomorrow I’m off to RailsConf Europe. Should be fun.

Updates:
  • the LTAC talk videos are here (thanks Ade).
  • the LTAC slides are here

Tags , , , , , , , , ,  | 1 comment

New Mocha Docs

Posted by James Mead Sun, 03 Sep 2006 18:20:00 GMT

Spurred on by Thorsten’s comment on Gluttonous’ blog and a mention of Mocha in the Top 5 Rails Stories of the Week, I’ve given the Mocha documentation a major overhaul.

Now the RDoc only shows the public API which should hopefully improve the signal-to-noise ratio and show how simple it is to use.

I’ve also had a play with CodeRay and generated syntax-highlighted examples.

Good general information on mocking…

Tags , , , , , , , , , , , , ,  | 4 comments