2012-01-10 6 views
4

FESTベースのGUIテストの新機能です。アプリケーションがロードされるのを待つようにする

MyFrameは自分のアプリケーションのルートクラスです。

@Before  
     public void onSetUp() { 

     MyFrame frame = GuiActionRunner.execute(new GuiQuery<MyFrame>() { 
      protected MyFrame executeInEDT() { 
       return new MyFrame(); 
      } 
     }); 

     frame2 = new FrameFixture(robot(), frame); 

     frame2.show(); // shows the frame to test 
     } 

Iは、テストケースを実行

@Test public void testGui() 
     { 
      String rs = frame2.label("hl").text().toString(); 
        assertTrue(rs.equals("First")); 
     } 

上記方法は、ラベル内に存在する実際の文字列を印刷しません。

FEST APIがアプリケーションの読み込みを待機していないと思います。

GUI要素の参照を延期する方法はありますか?

+0

私の答えはこちらhttp://stackoverflow.com/questions/8957334/making-fests-component-lookup-mechanism-wait-for-a-component-to-exist/11738497#11738497 – Whimusical

答えて

4
//do your clicks 
fixture.robot.waitForIdle();//give the GUI time to update 
//do your asserts 

ここで見てください。 Pauseの利点は、長い時間間隔を渡すことにより、必要以上に長く待つ必要がないことです。