assertj / assertj/assertj-swing
Testing issues with org.openide.DialogDisplayer
まだ誰も着手していません。
- 主要言語
- Java
- スター
- 121
- フォーク
- 52
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
Issue by Mark Corkery from Thu, 24 Sep 2009 04:53:11 -0500
Originally opened as http://jira.codehaus.org/browse/FEST-226
I'm having issues testing NetBeans Platforms DialogDescriptor. If I am testing the behavior in more than one test case the robot will not find the dialog panel in any test subsequent to the first test case which means that only the first test will pass. Netbeans Platform is
included as part of the standard netbeans IDE download. See the following page for more: http://platform.netbeans.org/
Testcase:
shouldDisplayDialog2(com.login.view.LoginFormTest):
Caused an ERROR
Timed out waiting for dialog to be found using matcher
org.fest.swing.core.matcher.DialogMatcher[name=<Any>, title='Hello',
requireShowing=false]
org.fest.swing.exception.WaitTimedOutError: Timed out waiting for
dialog to be found using matcher
org.fest.swing.core.matcher.DialogMatcher[name=<Any>, title='Hello',
requireShowing=false]
at org.fest.swing.timing.Pause.pause(Pause.java:74)
at org.fest.swing.timing.Pause.pause(Pause.java:58)
at org.fest.swing.fixture.ContainerFixture.findDialog
(ContainerFixture.java:165)
at org.fest.swing.fixture.ContainerFixture.dialog
(ContainerFixture.java:148)
at org.fest.swing.fixture.ContainerFixture.dialog
(ContainerFixture.java:143)
at com.login.view.LoginFormTest.shouldDisplayDialog2
(LoginFormTest.java:85)
I've created a cut down version of what my test looks like below (LoginForm could be replaced with any default JPanel object) :
package com.login.view;import org.fest.swing.driver.ComponentStateValidator;
import org.fest.swing.edt.FailOnThreadViolationRepaintManager;
import org.fest.swing.edt.GuiTask;
import org.fest.swing.fixture.Containers;
import org.fest.swing.fixture.DialogFixture;
import org.fest.swing.fixture.FrameFixture;
import org.fest.swing.core.matcher.DialogMatcher;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openide.DialogDescriptor;
import org.openide.DialogDisplayer;
import static org.fest.swing.edt.GuiActionRunner.*;public class LoginFormTest {
<span class="code-keyword">private</span> LoginForm loginForm; <span class="code-keyword">private</span> FrameFixture testPanelFixture = <span class="code-keyword">null</span>; @BeforeClass <span class="code-keyword">public</span> <span class="code-keyword">static</span> void setUpOnce() { FailOnThreadViolationRepaintManager.install(); } @Before <span class="code-keyword">public</span> void setUp() { execute(<span class="code-keyword">new</span> GuiTask() { @Override <span class="code-keyword">protected</span> void executeInEDT() <span class="code-keyword">throws</span> Throwable { loginForm = <span class="code-keyword">new</span> LoginForm(); } }); testPanelFixture = Containers.frameFixtureFor(loginForm); <span class="code-comment">//Aways call wait <span class="code-keyword">for</span> idle after using the GuiActionRunner.testPanelFixture.robot.waitForIdle();
}@After <span class="code-keyword">public</span> void cleanUp() { testPanelFixture.robot.cleanUp(); } @Test <span class="code-keyword">public</span> void shouldDisplayDialog() <span class="code-keyword">throws</span> Exception { <span class="code-keyword">final</span> DialogDescriptor dd = <span class="code-keyword">new</span> DialogDescriptor(<span class="code-quote">"Hello"</span>, <span class="code-quote">"Hello"</span>); DialogDisplayer.getDefault().notifyLater(dd); <span class="code-keyword">final</span> DialogFixture loginDialog = testPanelFixture.dialog(DialogMatcher.withTitle(<span class="code-quote">"Hello"</span>)); ComponentStateValidator.validateIsShowing(loginDialog.component()); loginDialog.focus(); } @Test <span class="code-keyword">public</span> void shouldDisplayDialog2() <span class="code-keyword">throws</span> Exception { <span class="code-keyword">final</span> DialogDescriptor dd = <span class="code-keyword">new</span> DialogDescriptor(<span class="code-quote">"Hello"</span>, <span class="code-quote">"Hello"</span>); DialogDisplayer.getDefault().notifyLater(dd); <span class="code-keyword">final</span> DialogFixture loginDialog = testPanelFixture.dialog(DialogMatcher.withTitle(<span class="code-quote">"Hello"</span>)); ComponentStateValidator.validateIsShowing(loginDialog.component()); loginDialog.focus(); }}
votes (original issue): 0
watches (original issue): 0
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
LoginFormTest.java の 85 行目付近から始め、shouldDisplayDialog と shouldDisplayDialog2 で失敗を再現します。DialogDisplayer.notifyLater、ContainerFixture.dialog、そして robot のクリーンアップ動作を追跡します。setup と cleanup の後に、両方のテストで Hello ダイアログを見つけて検証できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- java
- 領域
- desktop, testing
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100