NBehave Experiment: MonoRail Controllers & Rhino Mocks
…whoever keeps His word, truly the love of God is perfected in him. By this we know that we are in Him. — 1 John 2:5
Well I decided it was finally time I took a look at NBehave as another one of those tools to have in my toolbox. NBehave’s primary use seems to be in the domain model for implementing stories from the user’s perspective, which obviously sounds very powerful.
But I specifically wanted to see how NBehave would “behave” (sorry…) for driving out my MonoRail controllers along with mock objects for mocking out the back-end services as I do now. In other words, making the controller itself, the “person” interacting with the system using controller-specific terminology.
So I thought I would take one of my existing controller tests and convert it to a NBehave-type story/scenario. Here is my original old-school test:
Since I tend to be very verbose in my test naming, sometimes they can become unwieldy. Of course every time my test names get too long, I start questioning whether the unit of code I’m testing is trying to do too much, thus violating SRP. But in this case, I’m simply loading up 3 pieces of data from various services. (Yes, I realize the service communication here is becoming a bit chatty, and a refactoring task is definitely on the radar, but that’s not really the focus for this post). 🙂
Anyway, I wanted to see what this test would look like as a NBehave story. Here goes…
(sorry for the code wrappage)
But the real beauty is the generated output: