私はかなり複雑な JavaFx 2 アプリケーションを作成しましたが、そのために多数の単体テストを作成したいと考えています。問題は、テストを実行しようとすると、初期化されていないツールキットについて不平を言うランタイム エラーが発生することです。
私が言えることから、 @BeforeClass メソッドで何らかの方法で Application.launch() を呼び出す必要がありますが、 Application.launch() が呼び出し元のスレッドに戻らないため、デッドロックが発生します。
質問は、JavaFx をどのように初期化すればよいですか?
これは、機能しないコードのスケルトンです。
public class AppTest extends Application {
@BeforeClass
public void initialize() {
launch(); //this causes a deadlock
}
@Test
public void test1() {
//conduct test here
}
@Test
public void test2() {
//conduct other test here
}
@Override
public void start(Stage arg0) throws Exception {
}
前もって感謝します!