Thursday, May 08, 2008

XUnit.Net's [Fact] and [Theory] attributes

Following a debate with Dave yesterday I got to thinking (it's a rare event, and I like to revel in it when it happens). There may be technical reasons why you have to use [Fact] for a "regular" unit test (oh, I know it's not a unit test, it's a specification, humour me) and [Theory] for "data driven" tests. But from a usage point of view, why should I care if it's data driven or not? Wouldn't it be nice if the test runner would be able to identify a parameterless method and say "hey, this must be a regular unit test". Also,if the method has parameters it could be smart enough to say "hmm... this must be a data driven test. Do I have any data available?". If the developer hasn't provided any data, then the test, I mean spec, fails.

I think I fall on Dave's side of the argument that this feels like changing somewhat standardized terminology just for the sake of being different (or maybe it's trendy to keep up with the Ruby folks?).

What do you think, dear reader?

3 comments:

Dave Harris said...

I think I agree completely! :)

But seriously, you make a great point about whether it is really necessary to have two separate attributes.

Steve said...

I'm with Dave on this one... http://homepage.mac.com/stevevrporter/blog/Ta.html#bmo231951211

Ta.
Steve Porter

Taumuon said...

I've posted the same comment to a few people just now, hope you don't think I'm spamming you!

anyway, I blogged a while ago on the difference between theories and POUT, it'd be great to see what feedback you have.

http://taumuon-jabuka.blogspot.com/2008/03/comparing-theories-to-more-traditional.html

thanks,

Gary