[jbosscache-dev] poll: java tag for shortcut set up methods created only for UT purposes?

Brian Stansberry brian.stansberry at redhat.com
Wed Jul 11 16:16:40 EDT 2007


Why do you need a tag for that, rather than Javadoc? The only advantage 
I could see for a tag would be if there were tool support for it so the 
method didn't show up in code completion or something. Doubt that's 
gonna happen.

I've certainly seen methods like you describe, and have probably written 
some. Seems better to avoid if possible, particularly if invoking the 
method screws things up if you don't understand the secrets of the class.

Slightly off topic, but I generally prefer writing a lot of interfaces 
and clearly stating in both the interface javadoc and the impl class 
javadoc that the interface is the API (or SPI). I then feel more 
comfortable about adding methods to the impl class.

Galder Zamarreno wrote:
> Hi,
> 
> Quite often when contributing in JBoss projects, I create extra 
> protected methods (i.e. setters)
> to make my life a lot simpler when coding unit tests. People have 
> different opinions (such as
> the messaging guys who believe every single UT should be coded to the 
> public API), but I
> personally believe that you shouldn't be necessarily forced to set up a 
> complete environment
> to run a specific UT. There're a lot of situations where it makes sense 
> to do this, but others where
> not, and in the latter, having "shortcut" set up methods helps.
> 
> Sometimes, this "shortcut" methods are already there but other times are 
> not, hence my tendency
> to create these protected methods.  Now, wouldn't it be nice if there's 
> a Java tag
> that could be applied to this methods to indicate that:
> 
> "this method is only here to make my unit-testing-coding-life easier and 
> so, should only be called from
> unit tests, not from production code"
> 
> I had a quick look around and could not find anything. Do people 
> agree/disagree with creating such tag?
> 
> Cheers,
> 
> Galder
> _______________________________________________
> jbosscache-dev mailing list
> jbosscache-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/jbosscache-dev


-- 
Brian Stansberry
Lead, AS Clustering
JBoss, a division of Red Hat
brian.stansberry at redhat.com




More information about the jbosscache-dev mailing list