Search the web
Sign In
New User? Sign Up
altdotnet · Alt Dot.Net Discussions
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Show off your group to the world. Share a photo of your group with us.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Unit test over specification   Message List  
Reply | Forward Message #3802 of 23251 |

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?



--
Thanks,

Roy Osherove
www.TypeMock.com - Simplify Unit Testing

Author of "The Art Of Unit Testing" ( http://ArtOfUnitTesting.com )
www.ISerializable.com (blog)

Sat Mar 1, 2008 9:08 pm

royosherove
Offline Offline
Send Email Send Email

Forward
Message #3802 of 23251 |
Expand Messages Author Sort by Date

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...
Roy Osherove
royosherove
Offline Send Email
Mar 1, 2008
9:08 pm

A few simple examples of overspecification: - A test that depends on multiple unrelated concerns in order to accomplish its tasks. -> Should be using mocks...
Jeff Brown
xeeyore42
Online Now Send Email
Mar 1, 2008
9:38 pm

... (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 ...
Colin Jack
colin.jack
Offline Send Email
Mar 1, 2008
10:27 pm

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...
Alan Dean
alan_james_dean
Offline Send Email
Mar 2, 2008
2:16 am

... 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...
Ian Cooper
ian_hammond_...
Offline Send Email
Mar 2, 2008
1:08 pm

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 Wilde
tj.wilde
Offline Send Email
Mar 2, 2008
11:56 pm

... 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...
Ian Cooper
ian_hammond_...
Offline Send Email
Mar 3, 2008
9:51 am

... 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....
Colin Jack
colin.jack
Offline Send Email
Mar 3, 2008
10:35 am

... Hmmm, let's see if I can put together a blog post...
Ian Cooper
ian_hammond_...
Offline Send Email
Mar 3, 2008
12:41 pm

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....
Roy Osherove
royosherove
Offline Send Email
Mar 3, 2008
1:45 pm

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...
Sebastien Lambla
serialseb
Offline Send Email
Mar 3, 2008
2:13 pm

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...
Roy Osherove
royosherove
Offline Send Email
Mar 3, 2008
2:24 pm

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...
Sebastien Lambla
serialseb
Offline Send Email
Mar 3, 2008
4:17 pm

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...
Roy Osherove
royosherove
Offline Send Email
Mar 3, 2008
4:20 pm

... 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, ...
Brad Wilson
bradw_64
Offline Send Email
Mar 3, 2008
3:26 pm

perhaps what really want to do is to have an B expectedB = new B(). b.settSomeValue(xxx) Assert.AreEqual(expectedB, actualBAfterItHasBeenUsedByMyCLass) So you...
Roy Osherove
royosherove
Offline Send Email
Mar 3, 2008
3:58 pm

As a general rule, I don't override Object.Equals() just for the sake of unit tests. I have no problem with several asserts instead of one....
Brad Wilson
bradw_64
Offline Send Email
Mar 3, 2008
4:20 pm

Brad, Asserting a single thing in a test doesn't necessarily means a single Assert.Foo call. It means that you are asserting a single action...
Ayende Rahien
Ayende@...
Send Email
Mar 3, 2008
5:23 pm

I agree, but Roy apparently does not. :)...
Brad Wilson
bradw_64
Offline Send Email
Mar 3, 2008
5:25 pm

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 ...
Roy Osherove
royosherove
Offline Send Email
Mar 3, 2008
8:15 pm

... 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...
Colin Jack
colin.jack
Offline Send Email
Mar 3, 2008
7:19 pm

Agreed. In general, mocking stuff like that is self defeating in the long term. Mocking something like this is not: IUserRepository.GetPagedUserByClient("foo",...
Ayende Rahien
Ayende@...
Send Email
Mar 3, 2008
7:23 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help