A few weeks ago Oren (known to many as Ayende Rahien) pushed out a Rhino.Mocks beta drop so we could take a look at the new Arrange/Act/Assert syntax being cooked up for the pending 3.5 release. Yesterday I finally upgraded my client project to the 3.5 beta bits and started digging into the new syntax.
AAA, FTW!
After using Arrange/Act/Assert for just a day or two I’m already hooked. It feels like a much more natural fit for bdd-style tests.
The whole Given, Expect, When, Then, go-back-and-verify-expectations flow always felt clumsy and counterintuitive, and AAA allows for a more natural Given, When, Then, Verify Expectations.
If that doesn’t make a whole lot of sense, don’t worry… I’m planning a follow-up post to dive a bit deeper and hopefully illustrate the point. For now though, I’d encourage you to go take a look at the Rhino.Mocks tests to get a feel for what you can do with the AAA syntax.
Faster is better…
Aaron Jensen did some digging and was able to speed up performance by a pretty noticeable amount – nearly 50% according to his measurements.
And not that I don’t trust Aaron’s measuring abilities or something, but I decided to do some measuring of my own. I upgraded a current client project and I can confirm, these Rhinos are turbo-charged!
I ran our UnitTests project, which at the time had 1566 tests with none of hitting a database, external resource, etc…, but a majority of them do rely pretty heavily on mocks.
I wasn’t nearly as scientific as Aaron. In fact I was straight-up lazy, running the test project using the most handy mechanism at my disposal - TestDriven.net.
I did a few runs using Rhino.Mocks 3.4 (test runs #1 and 2 in the above picture) and then a couple more with 3.5 (runs #3 and 4). And my totally unscientific results showed… drum roll please… the new bits to be about 50% faster. Sweet!
