1 | package gstests.tutorials;
|
---|
2 |
|
---|
3 | /*
|
---|
4 | Using AssertJ Swing to do Java GUI testing (of swing classes)
|
---|
5 | - Obtain from: https://search.maven.org/search?q=assertj-swing-junit
|
---|
6 | - Documentation: https://joel-costigliola.github.io/assertj/assertj-swing.html
|
---|
7 |
|
---|
8 | Alternatives to AssertJSwing:
|
---|
9 | https://sqa.stackexchange.com/questions/18554/open-source-tools-for-automation-of-java-gui-application-testing
|
---|
10 |
|
---|
11 | Event Dispatch Thread (EDT) pages:
|
---|
12 | - https://web.archive.org/web/20120526191520/http://alexruiz.developerblogs.com/?p=160
|
---|
13 | - https://web.archive.org/web/20130218063544/http://weblogs.java.net/blog/alexfromsun/archive/2006/02/debugging_swing.html
|
---|
14 |
|
---|
15 | */
|
---|
16 |
|
---|
17 | import org.junit.AfterClass;
|
---|
18 | import org.junit.Assert;
|
---|
19 | import org.junit.Before;
|
---|
20 | import org.junit.Test;
|
---|
21 |
|
---|
22 | import org.greenstone.gatherer.GathererProg; // main GLI class we'll be testing
|
---|
23 |
|
---|
24 | import org.assertj.swing.junit.testcase.AssertJSwingJUnitTestCase;
|
---|
25 | import org.assertj.swing.fixture.FrameFixture;
|
---|
26 | import org.assertj.swing.edt.GuiActionRunner;
|
---|
27 |
|
---|
28 | // static imports
|
---|
29 | import static org.assertj.swing.launcher.ApplicationLauncher.*;
|
---|
30 |
|
---|
31 |
|
---|
32 | public class RunGLITest extends AssertJSwingJUnitTestCase {
|
---|
33 | private FrameFixture window;
|
---|
34 |
|
---|
35 | @Override
|
---|
36 | protected void onSetUp() {
|
---|
37 | GathererProg frame = GuiActionRunner.execute(() -> new GathererProg());
|
---|
38 | // IMPORTANT: note the call to 'robot()'
|
---|
39 | // we must use the Robot from AssertJSwingJUnitTestCase
|
---|
40 |
|
---|
41 | //window = new FrameFixture(robot(), frame);
|
---|
42 | //window.show(); // shows the frame to test
|
---|
43 |
|
---|
44 | // Launch GathererProg.java's main() method
|
---|
45 | // See https://joel-costigliola.github.io/assertj/assertj-swing-launch.html
|
---|
46 |
|
---|
47 | String GSDLOS = System.getenv("GSDLOS");
|
---|
48 | String GSDLHOME = System.getenv("GSDLHOME");
|
---|
49 | String GSDL3HOME = System.getenv("GSDL3HOME");
|
---|
50 | String GSDL3SRCHOME = System.getenv("GSDL3SRCHOME");
|
---|
51 | application("org.greenstone.gatherer.GathererProg").withArgs(
|
---|
52 | "-gsdl", GSDLHOME,
|
---|
53 | "-gsdlos", GSDLOS,
|
---|
54 | "-gsdl3", GSDL3HOME,
|
---|
55 | "-gsdl3src", GSDL3SRCHOME).start();
|
---|
56 | }
|
---|
57 |
|
---|
58 | @Test
|
---|
59 | public void shouldCopyTextInLabelWhenClickingButton() {
|
---|
60 | System.err.println("@@@ First test");
|
---|
61 | //window.textBox("textToCopy").enterText("Some random text");
|
---|
62 | //window.button("copyButton").click();
|
---|
63 | //window.label("copiedText").requireText("Some random text");
|
---|
64 | }
|
---|
65 | }
|
---|