Click here to Skip to main content
11,798,866 members (42,479 online)
Rate this: bad
Please Sign up or sign in to vote.

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:

Data Access Layer
Business Logic Layer
Service API Layer
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 9:16am

1 solution

Rate this: bad
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,[^].

thatraja at 6-Jun-12 16:25pm
SAKryukov at 6-Jun-12 18:23pm
Thank you, Raja.
idle63 at 6-Jun-12 16:25pm
hmmm....still still amazed. Good pragmatic answer ... 5
SAKryukov at 6-Jun-12 18:23pm
Thank you.
Manas Bhardwaj at 6-Jun-12 16:34pm
well said +5
SAKryukov at 6-Jun-12 18:23pm
Thank you.
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.

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

  Print Answers RSS
0 CPallini 465
1 OriginalGriff 378
2 Maciej Los 305
3 Richard MacCutchan 281
4 phil.o 244
0 OriginalGriff 2,270
1 Maciej Los 1,810
2 KrunalRohit 1,496
3 CPallini 1,425
4 Richard MacCutchan 1,109

Advertise | Privacy | Mobile
Web02 | 2.8.151002.1 | Last Updated 6 Jun 2012
Copyright © CodeProject, 1999-2015
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