This is really the third attempt at an ‘expect()’ implementation that allows multiple failures per test.

First attempt was a general solution that works with any test framework, but with a slightly clunky API. The main problem with it was that it required the test to call a final ‘assert_expectations()’ from the test code. If you forgot to call that function, the failures weren’t reported.

Occasionally referred to as Test First Development, Test First Programming is a beautiful concept that radically changed the way I approach software development.

The ideas of Test First Programming and Test Driven Development are often muddled together.
However, Test First is powerful enough to stand on it’s own.
I think it’s important to present the concepts separately.

TDD and many other agile practices build on Test First.
This isn’t just about remembering the past.
The lessons learned from Test First are still very important.

In Delayed assert / multiple failures per test, I presented a first attempt at writing an ‘expect()’ function that will allow
a test function to collect multiple failures and not stop execution until the end of the test.

There’s one big thing about that method that I don’t like.
I don’t like having to call ‘assert_expectations()’ within the test.
It would be cool to push that part into a plugin.

So, even though this isn’t the prettiest code, here’s a first attempt at making this a plugin.