[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[jfw] Re: Private methods should not be unit-tested



All generalizations are wrong. For me it depends on the complexity of the method. Regression tests are wonderful things that can save a lot of time and significantly improve overall quality.

Generally as Feathers notes, this is first and foremost an argument against private methods. IMO if you have something private it should be short and sweet and really easy to test. This isn't an argument for writing tests for those sorts of methods, it's an argument against. However sometimes there's complex code that needs to be private, and I think complex code needs tests no matter what the scope is.

I agree that interface tests have more long term value, but my experience has been that it takes no more effort to build a small unit test than it does to construct an ad-hoc environment that does the same job, and often it takes much less. The trick is to remember that tests written for methods that aren't part of the interface should be considered as disposable as those ad-hoc tests, if the internal implementation changes.

--
Framework source code: https://github.com/joomla/joomla-framework
Visit http://developer.joomla.org for more information about developing with Joomla!
---
You received this message because you are subscribed to the Google Groups "Joomla! Framework Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-framework+unsubscribe AT googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-framework.