Using code generation in tests
April 20th, 2006
Not sure if this falls into the useful or into the weird category, but I’m beginning to do code generation in my behavior specifications…
Take a look at the behavior specification:
And the corresponding implementation:
Nothing too earth shattering, except for the specs. How do I ensure the specs were properly generated ? I didn’t, except for confirming that the number of tests and assertions went up as expected.
October 12th, 2007 at 10:25 PM
That code sure smells Enterprisey to me. It looks like you’re jumping through a lot of hoops just to assert that “approved” == “approved” and “approved” != “started”.
Is TransactionStateOrderingTest really testing something that might break? In fact, is TransactionState any more useful than StatusNames would be on it’s own?
October 12th, 2007 at 10:25 PM
Sure, TransactionState allows me to encapsulate ordering calculations. That way, Transaction doesn’t need to know about it.
I knew it smelled… Probably time to change that diaper.