source: gs3-extensions/testing/trunk/src/src/gstests/tutorials/RunGLITest.java@ 32683

Last change on this file since 32683 was 32683, checked in by ak19, 5 years ago
  1. Rudimentary test class for running GLI with Assertj Swing. 2. Already accidentally prematurely committed major changes in revision 32680 to ext/testing/build.xml which starts using assertj-swing. I think it's now successfully launching GLI. The reason I may not be seeing GLI's GUI when testing may perhaps be since there are no actual tests yet other than to run and quit GLI. The changes to build.xml in this commit are cosmetic, but wanted a commit message explaining the new targets introduced in revision 32680, which were to compile up and build our tutorial testing classes. At present there's only one class which doesn't do much yet, as explained. But at least I got the ant target's classpath correct to get it compiled and for JUnit to start running the basic test class.
File size: 2.3 KB
Line 
1package gstests.tutorials;
2
3/*
4Using 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
8Alternatives to AssertJSwing:
9https://sqa.stackexchange.com/questions/18554/open-source-tools-for-automation-of-java-gui-application-testing
10
11Event 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
17import org.junit.AfterClass;
18import org.junit.Assert;
19import org.junit.Before;
20import org.junit.Test;
21
22import org.greenstone.gatherer.GathererProg; // main GLI class we'll be testing
23
24import org.assertj.swing.junit.testcase.AssertJSwingJUnitTestCase;
25import org.assertj.swing.fixture.FrameFixture;
26import org.assertj.swing.edt.GuiActionRunner;
27
28// static imports
29import static org.assertj.swing.launcher.ApplicationLauncher.*;
30
31
32public 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}
Note: See TracBrowser for help on using the repository browser.