Subject: DocOz - melt fat - guide

From: DocOz Exclusive <[email-masked]>
Date: Thu, 12 Jun 2014 13:26:56 -0700

Weight-Loss Trick for EVERY Body Type

Melt Fat no matter what your shape. 
This proven tip will have you shedding pounds in a few days.

Kiss that Fat goodbye immediately.

View DocOz Clip: http://www.agawhich.com/DocOz/Personal/invitation.index
Episode 401

Get comfortable in you own skin once and for all...

- DocOz Show

we hoped you enjoyed this DocOz Alert. 

- Changes to notification status can be sent to: Member Update Systems
at 9167 ROAD 177_Oakwood, OH 45873 or http://www.agawhich.com/w4iehjf.srgtr4

I don't understand why testing a private method creates code smell? Is not the point of unit testing to test each small part to isolate errors. could you explain what a brittle test is please?   Ben Page Mar 20 '09 at 21:38
17	  	
A brittle test is a test which fails too easily when there's a change in the code. Generally this happens when the test result is based on what the method does rather than on the expected outputs and side-effects given a set of inputs. Ideally, a change to the code which does not change the results should not break the test.   aro_biz May 13 '09 at 8:43
62	  	
@Mr. Shiny and New: If your private method is complex enough to warrant independent unit testing, then it's complex enough to have its own class. The class can be internal of course (i.e. not accessible from other packages).   sleske Oct 2 '10 at 22:59
2	  	
But isn't an internal class adding more complexity to something that maybe is complex to understand but are 4 lines of code extracted to a private method to avoid repetition?   Rafa de Castro Dec 1 '10 at 11:14
24	  	
@sleske, I don't agree. You can have a small private method which by design you needed it to be private. and I would rather test each small piece of code, than test that private method through a public one. This way of testing will go towards a component test.   despot Aug 4 '11 at 11:51
2	  	
Having more finely grained tests that cover smaller private methods mean when things do break, your tests will tell you where. After all, coding input and outputs are /assumptions/, and we test these assumptions remain true. If your internal "brittle" test breaks, then the assumption about how it works has changed, and code that uses it will probably be broken in subtle ways.   Kent Fredric May 10 '12 at 4:55
1	  	
( Usually, when a test starts failing, you'll reach for the debugger to find out why, having smaller sub-tests will make finding the place the fault occurs much faster )   Kent Fredric May 10 '12 at 4:57
3	  	
The test-the-private-method camp is missing the point: it can take a great deal more work and time to test the private methods, and it's not likely to save any/enough time when a test fails. If the test fails for some error in a private method like an NPE, you'll still be taken right to the problem (the private method). If the data generated by a private method don't match, you can easily see that in your assertion by debugging equals(). In some cases, it may make sense to write tens of private method tests using reflections, but the need should be clearly visible.   Pete Jul 7 '12 at 2:12 
7	  	
@Pete I agree. My team tests private methods and I feel like I waste a lot of time "fixing" unit tests for private methods that start failing after I change around how the private internals of a class work, without changing the class's contract. I look at the failing tests and it's now failing because private method f was not called 3 times, or private method g returned some different result. Yet the public tests do not break. To me that is a waste and is not very helpful having those tests. 2 seconds on a debugger will show me where some public method fails.