Skip to content

Instantly share code, notes, and snippets.

@teguhteja
Last active March 23, 2020 11:23
Show Gist options
  • Save teguhteja/ad0f9e7152efae5671b09446e02c4753 to your computer and use it in GitHub Desktop.
Save teguhteja/ad0f9e7152efae5671b09446e02c4753 to your computer and use it in GitHub Desktop.
Test of SimpleCopyApplication
package com.ttm.testswingmaven;
import org.assertj.swing.aut.getting_started.SimpleCopyApplication;
import org.assertj.swing.edt.FailOnThreadViolationRepaintManager;
import org.assertj.swing.edt.GuiActionRunner;
import org.assertj.swing.fixture.FrameFixture;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
public class SimpleCopyApplicationTest {
private FrameFixture window;
@BeforeClass
public static void setUpOnce() {
FailOnThreadViolationRepaintManager.install();
}
@Before
public void setUp() {
SimpleCopyApplication frame = GuiActionRunner.execute(() -> new SimpleCopyApplication());
window = new FrameFixture(frame);
window.show(); // shows the frame to test
}
@Test
public void shouldCopyTextInLabelWhenClickingButton() {
window.textBox("textToCopy").enterText("Some random text");
window.button("copyButton").click();
window.label("copiedText").requireText("Some random text");
}
@After
public void tearDown() {
window.cleanUp();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment