- Last edited February 28, 2002 |
In the past we've made those methods protected, then extended the class we want to test in our test package, allowing us to access those protected methods. But this is ugly and causes confusion.
I've never understood why putting your test classes in the same package as production code is considered 'bad'. I've always placed them in the same package, and never had a problem. And as private methods ultimately have to be called by a non-private method, they are testable 'by proxy'. Am I missing something? --DarrenHobbs
Java 1.2 gives you a neat solution. If you grant your test code the java.lang.reflect.ReflectPermission then you can call private methods.
--OliBye
- Last edited February 28, 2002 |