Julius Stroffek wrote:
Hi All,

I deal with a problem of testing a functionality of private classes.

<snip>

Bryan pointed me at the discussion at http://www.nabble.com/Re%3A-JUnit-unit-tests---parallel-test-three--p5711307.html where Kristian discussed this couple months ago. I talked to Kristian and he told me that the problem was not solved at that time.

I have only two solutions to this:

1.) Change the visibility of required classes to public.
2.) Maintain the parallel package tree (suggested by Krisitian) with implementation of tests of private classes.
<snip>

Just wondering, does anyone know if using reflection to bypass the Java access protection (as Kristian mentioned in the above mentioned thread) is completely out of the question?

I'm asking because it is mentioned in the JUnit FAQ, and discussed in [1], although the article does not cover private classes, only fields and methods/constructors.


--
John

[1] "Subverting Java Access Protection for Unit Testing" - http://www.onjava.com/pub/a/onjava/2003/11/12/reflection.html

Reply via email to