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

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

Mmm, sorry, still didn't really answer Karthik's question: of course he specifically means Joomla\Test\TestHelper
I'll have a look at that; haven't really studied that one yet.

On Saturday, 15 March 2014 09:10:48 UTC+1, Herman Peeren wrote:
Oops, sorry Karthik, I was too quickly with my answer and didn't answer your question. I just saw the word helper-class and that works on me like a red cloth on a bull...

To answer your question: a TestHelper class is to help testing a class from the outside, making testing more "transparent". Even if it would be possible to reach private methods with it, you are then not testing the interface, but the implementation. So: it is an indication that you are doing something wrong... Of couse you can use it during development or when searching for a bug, but I think the use of private methods in tests also indicate an architectural flaw.

BTW, nice article by our PHP-hero Giorgio Sironi about the Test Helper pattern:

On Saturday, 15 March 2014 08:53:25 UTC+1, Herman Peeren wrote:
On Saturday, 15 March 2014 04:08:25 UTC+1, Karthik Narendran wrote:
Just one question; then why TestHelper class? It was designed for direct access to Private / Protected methods and variables right? And for working with Reflection API.

All those helper-classes with their static methods are in fact a kind of function-libraries. It is a typically procedural coding style, not object oriented. Such helper-classes should be avoided. They are a code-smell, an anti-pattern. And yes: some refactoring to do for that to get rid of them in Joomla...

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.