Click here to Skip to main content
15,868,164 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

1 solution

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
 
Share this answer
 
v2
Comments
thatraja 6-Jun-12 16:25pm    
5!
Sergey Alexandrovich Kryukov 6-Jun-12 18:23pm    
Thank you, Raja.
--SA
[no name] 6-Jun-12 16:25pm    
hmmm....still still amazed. Good pragmatic answer ... 5
Sergey Alexandrovich Kryukov 6-Jun-12 18:23pm    
Thank you.
--SA
Manas Bhardwaj 6-Jun-12 16:34pm    
well said +5

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900