Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hi,
 
I have a question about finding the best balance of unit testing. I have in one example a website which consumes a services for its data. If I break the solution down I have the following layers:
 
Service
Data Access Layer
Business Logic Layer
Service API Layer
Website
Service Client Layer
Application Data Manager Layer
Form Model Layer
 
I could write unit tests for just the form model layer and the service api layer which would give 100% code coverage and would identify breaking changes between the application and the service. Do most of you think that would be sufficient or would there be merit developing unit tests for all of the layers?
Posted 6-Jun-12 10:16am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

No one can tell you the exact answer. It really depends on your project in further detail. I hope I don't have to proof that testing cannot proof anything? More exactly, you can proof there is a defect, but otherwise, if testing finds no defects, it cannot proof that all defects are fixed, no matter how much you test. So, the amount and set of subjects for testing should be made dependent on some logical analysis, nature, architecture and design of your project; and the decision should be based on a good amount of common sense.
 
Now, I would note that the layers are not really units, unless your project is really small. In a considerably big and/or complex project the units should be much smaller. The units should be tested on the minimal fine-grain level, in some bigger groups in collaboration. Again, it depends on your design; but not just this; rather, all you design should include and take into account the testing and promote the "testability" of the units and collaboration.
 
Finally, I would not advise to skip any layers from testing. Again, it depends on your project, in particular, on the resources you can afford.
 
And, to finish with that, one not 100% relevant, but very interesting and somewhat related article:
Joel Spolsky, Top Five (Wrong) Reasons You Don't Have Testers,
http://www.joelonsoftware.com/articles/fog0000000067.html[^].
 
—SA
  Permalink  
v2
Comments
thatraja at 6-Jun-12 16:25pm
   
5!
SAKryukov at 6-Jun-12 18:23pm
   
Thank you, Raja.
--SA
idle63 at 6-Jun-12 16:25pm
   
hmmm....still still amazed. Good pragmatic answer ... 5
SAKryukov at 6-Jun-12 18:23pm
   
Thank you.
--SA
Manas Bhardwaj at 6-Jun-12 16:34pm
   
well said +5
SAKryukov at 6-Jun-12 18:23pm
   
Thank you.
--SA
Stephen Hewison 2 at 6-Jun-12 17:18pm
   
Thanks again for another detailed answer. I appreciate layers are not units. In my question I should explained that in most instances an application entity would have a unit in each of the listed layers. +5
SAKryukov at 6-Jun-12 18:22pm
   
Thank you for voting.
 
It looks like you agree this answer makes sense. If so, please also accept it formally (green button) -- thanks.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 400
1 Jochen Arndt 190
2 Richard MacCutchan 135
3 DamithSL 95
4 Garth J Lancaster 90
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,032
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,220


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 6 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100