Hi,

 

I tried testing swing application using JFC unit.I have a class  named
myclass.The class has a textbox and a button named mybutton.

I have a test class Testmyclass ,which checks for the existence of a
button in myclass.I used findNamedComponent () method .But my testcase
fails.

Please let me know how to use this method findNamedComponent().



Let's say my testclass looks like this,



import junit.extensions.jfcunit.*;

import junit.extensions.jfcunit.JFCTestCase;

import junit.extensions.jfcunit.TestHelper;

import junit.extensions.jfcunit.JFCTestHelper;



Class Testmyclass extends TestCase{

private myclass mi= null;

             private JButton clickme=null;

             private JFCTestHelper helper = null;

           

                                        

 

         public Testmyclass( String name ) {       

             super( name );  

         }

 



              protected void setUp() throws Exception {

              helper = new JFCTestHelper(); 

           

                          

              clickme=(JButton)
helper.findNamedComponent(myclass.class,"mybutton",0);

              System.out.println(clickme);                           

               System.out.println("iN setup");

                        flushAWT();      

            }



public void testnotnull() throws Exception{
           assertNotNull("Not found ",clickme);
//fails



}


protected void tearDown() throws Exception{

            super.tearDown();

            System.out.println("In tear down");

            }





}


Please help.

Meera Ramachandran