assertj / assertj/assertj-swing
Testing issues with org.openide.DialogDisplayer
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Java
- Estrellas
- 121
- Forks
- 52
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Empieza por LoginFormTest.java alrededor de la línea 85 y reproduce el fallo en shouldDisplayDialog y shouldDisplayDialog2. Sigue el flujo de DialogDisplayer.notifyLater, ContainerFixture.dialog y el comportamiento de limpieza del robot; se considera terminado cuando ambas pruebas pueden encontrar y validar el diálogo Hello después del setup y el cleanup.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- java
- Área
- desktop, testing
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100