I'm working on chapter 8 of my upcoming book and I need to come up with a good example of over specification in unit tests, that leads to an unmaintainable test in the long run (fragile test). I have my ideas on how to show it, but I'd love to know what you consider an over specified test, that can be shown with a concise (or even a bit contrived) code example.
- How would you define test over specification?
- how would you show it?
- are there multiple kinds of over specification with different ways to tackle them?
I'm working on chapter 8 of my upcoming book <http://artofunittesting.com/>and I need to come up with a good example of over specification in unit tests, that...
A few simple examples of overspecification: - A test that depends on multiple unrelated concerns in order to accomplish its tasks. -> Should be using mocks...
... (fragile ... I guess I'm influenced a lot by Meszaros but my main thoughts when I hear about over specification is what he describes as "overspecified ...
Roy, "Magic numbers are a code smell" VAT (a sales tax) is 17.5% here in the UK. You can just imagine the developer looking at a simplistic functional...
... A test that tells you how to implement the SUT instead of what it should achieve. Broadly, a test is over-specified if, in order to refactor (where...
This actually worries me a bit. As a lone, in-house developer (woe is me :P), I don't have anyone locally to bounce ideas off, so I read dozens of blogs,...
... Tim, as I pointed out in the BDD discussion, one thing to bear in mind is that there is no 'right' way to write your tests, just a set of approaches that...
... If you have time I'd be interested in more information about this as I've never got a good feeling for the amount/style of acceptance tests to write....
When I started writing about it, my definition of an over specified test was that is was a test the specified purely internal behavior, with no collaborators....
I would've thought it was quite reasonable to assert several conditions (range checking for example) in one test, I thin the one assertion per test is quite...
I tend to think that multiple asserts (on the same output) are an "Expected Object" waiting to be born, where you create an expected object. Range checking, to...
Thanks for reminding me that it throws, very much appreciated roy J That said, I find the assertion (pardon the punt) that it's a big issue that having several...
It's not an assertion. there are times where I think its OK, but I've seen plenty of times where multiple asserts lead to problems, mainly when they were...
... I will very often have tests which basically say "when I do this, it calls A with parameters X and Y to get value Z, cracks some set of values out of it, ...
perhaps what really want to do is to have an B expectedB = new B(). b.settSomeValue(xxx) Assert.AreEqual(expectedB, actualBAfterItHasBeenUsedByMyCLass) So you...
Roy "agrees" that you shouldn't be too dogmatic, and that most times I see multiple asserts used, it is not for good reason ... -- Thanks, Roy Osherove ...
... My feeling is that this might not be the way you would want to use mocking, I'd recommend reading "Mock Roles, Not Objects" but my view is whether you use...
Agreed. In general, mocking stuff like that is self defeating in the long term. Mocking something like this is not: IUserRepository.GetPagedUserByClient("foo",...