From: Jeffrey H. <jc...@gm...> - 2006-08-02 17:19:10
|
Actually, you can. You can access private methods and fields through reflection. See "Subverting Java Access Protection for Unit Testing" here: http://www.onjava.com/pub/a/onjava/2003/11/12/reflection.html On 8/2/06, Matthieu Casanova <cho...@gm...> wrote: > Hi, the problem will also to test the private methods. I think there is no > way to do that isn't it ? > > Matthieu > > 2006/8/2, Jeffrey Hoyt <jc...@gm... >: > > > I've done a lot of unit testing, but for back end stuff (web-based > software) and the non-GUI portions of a Swing application (examples > here: > http://autohostclient.cvs.sourceforge.net/autohostclient/autohostclient/src/test/stars/ahc/). > There are extensions to do GUI testing, but I've never evaluated > them. > > Basically with junit, you always test methods directly, but you have > to initialize all the stuff your method exercises first. With > something like jEdit, which was never written to support unit testing, > it may be very hard to initialize everything in a way that allows you > to test, especially if you are trying to hunt down GUI bugs. That may > be my unfamiliarity with core code talking, though. > > Jeff > > On 8/2/06, Alan Ezust <ala...@gm...> wrote: > > I'm playing around with junit 4.1 now. It's much nicer than version 3, > > and takes advantages of the Java 1.5 annotations, which is quite nice. > > So now I need to write a unit-test to reproduce a problem I am having > > with Lucene. I'm wondering how to initialize the unit test. Should it > > just start up the whole jEdit application? Or is there a way I can > > test the routines directly. > > > > Since the classes I want to test depend on jedit, and do things like > > jEdit.getProperty(), I need the property system to be loaded. > > > > Has anyone else written unit tests for pieces of jedit? How do you > > initialize your tests? > > > > > ------------------------------------------------------------------------- > > Take Surveys. Earn Cash. Influence the Future of IT > > Join SourceForge.net's Techsay panel and you'll get the chance to share > your > > opinions on IT & business topics through brief surveys -- and earn cash > > > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > -- > > ----------------------------------------------- > > jEdit Developers' List > > jEd...@li... > > https://lists.sourceforge.net/lists/listinfo/jedit-devel > > > > > -- > They that give up essential liberty to obtain a little temporary > safety deserve neither. > > ------------------------------------------------------------------------- > > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > -- > ----------------------------------------------- > jEdit Developers' List > jEd...@li... > https://lists.sourceforge.net/lists/listinfo/jedit-devel > > -- They that give up essential liberty to obtain a little temporary safety deserve neither. |