Changeset 39018
- Timestamp:
- 2024-05-13T22:17:12+12:00 (10 days ago)
- Location:
- gs3-extensions/testing/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-extensions/testing/trunk/README_2024
r39017 r39018 1 --------------------------- 2 Notes written 2024: 3 --------------------------- 4 I'm not sure what I read on junits, assertj swing and (if anything) on selenium to start off the automated gli testing work back in 2018, but here's what I can gather from current code. 1 ------------------------------------------------------------- 2 README Notes written 2024 3 (AssertJ Swing GLI GUI testing groundwork laid in 2018-2019) 4 ------------------------------------------------------------- 5 5 6 But the following may be useful websites 6 Sections 7 I Code Layout 8 II Background Reading 9 III Compiling and Running 10 11 12 ------------------- 13 CODE LAYOUT 14 ------------------- 15 - ext/testing/src/src/org/greenstone/gsdl3/testing/GSGUIUtil.java (Selenium, browser testing helper functions, needs revisiting in 2024) 16 - ext/testing/src/src/org/greenstone/gsdl3/testing/GSGUITestingUtil.java (AssertJ Swing, GUI testing helper functions) 17 - ext/testing/src/src/gstests/tutorials/RunGLITest.java (tests, rudimentary stage of testing the basic GUI helper functions above) 18 19 20 ------------------- 21 BACKGROUND READING 22 ------------------- 23 See the comments section at the top of ext/testing/src/src/gstests/tutorials/RunGLITest.java 24 It lists the URLs and reading that I went through pertaining to junits, assertj swing and (if anything) on selenium to start off the automated gli testing work back in 2018. 25 26 I can further gather the following from the current code. 27 28 The following may be useful websites 7 29 - interspersed throughout our code that uses assert swing, I find I'd added references to this website: https://joel-costigliola.github.io/assertj/assertj-swing-basics.html 8 30 … … 12 34 - there's also the older wiki page by Sam that has his own work (not yet incorporated): https://wiki.greenstone.org/doku.php?id=internal:gs3_automated_testing 13 35 14 36 ---------------------- 37 COMPILING AND RUNNING 38 ---------------------- 15 39 0. Have a fresh GS3, preferrably a code checkout from SVN so that you can tweak the code on any errors. 16 40 -
gs3-extensions/testing/trunk/src/src/gstests/tutorials/RunGLITest.java
r39016 r39018 68 68 import javax.swing.*; 69 69 70 // static imports 70 // static imports - call static functions without class as namespace qualifier 71 71 import static org.greenstone.gsdl3.testing.GSGUITestingUtil.*; 72 72 … … 82 82 private FrameFixture window; 83 83 84 // https://stackoverflow.com/questions/50815329/close-application-after-test-without-test-failure-using-assertj 85 // https://stackoverflow.com/questions/23139321/testing-java-gui-application-closing-window-during-test-ends-test-suite 86 // https://stackoverflow.com/questions/5401281/preventing-system-exit-from-api 87 /* 88 @BeforeClass 89 public static void initOnce() { 90 // to prevent system.exit from causing issues 91 org.assertj.swing.security.NoExitSecurityManagerInstaller.installNoExitSecurityManager(); 92 } 93 */ 84 94 // Selenium 85 95 @Before … … 99 109 @Override 100 110 protected void onSetUp() { 111 System.err.println("#### onSetUp called - running GLI"); 101 112 // Launch GLI and then get a ref to the launched app window: 102 113 runGLI(); … … 111 122 @Test 112 123 public void testGLIRunning() { 113 114 115 124 // waiting a few seconds for window, so we can see it 116 PAUSE(2); 117 125 PAUSE(2); 126 118 127 System.err.println("@@@ First test: GLI Running"); 119 120 /* 121 // See "Testing long duration tasks" at 122 // https://joel-costigliola.github.io/assertj/assertj-swing-lookup.html 123 DialogFixture lockfileDialog = WindowFinder.findDialog("LockFileDialog").using(robot());//new DialogFixture(robot(), "LockFileDialog"); //window.dialog("LockFileDialog", Timeout.timeout(1)); 124 if(lockfileDialog != null) { 125 lockfileDialog.click(); // bring to foreground in case JProgressBar hides it 126 lockfileDialog.button("LockFileDialog.ok_button").click(); 127 } 128 */ 128 129 129 // steal any collection lock that may or may not presents itself within param seconds 130 130 stealAnyCollectionLock(1); … … 150 150 // For testing, want GLI to be in librarian mode by default 151 151 changeUserMode("librarian"); 152 152 153 153 switchToPane(GATHER_PANE); 154 154 … … 166 166 167 167 exportCollection("GreenstoneMETS", "lucene-jdbm-demo"); 168 168 169 169 // Reset GLI to expert mode for regular GLI use 170 170 changeUserMode("expert"); … … 172 172 PAUSE(2); 173 173 174 switchToPane(GATHER_PANE); 175 176 //exitGLI(); //System.exit() on GLI won't allow quit to be called on Selenium's web _driver, why? 174 switchToPane(GATHER_PANE); 175 176 exitGLI(); //System.exit() on GLI won't allow quit to be called on Selenium's web _driver, why? Because System.exit exited the JUnit tests too 177 177 178 PAUSE(3); 178 179 } 180 181 182 @Test 183 public void tutorial_tests() { 184 /* 185 // Preliminaries 186 // waiting a few seconds for window, so we can see GLI running 187 PAUSE(2); 188 189 System.err.println("@@@ First test: GLI Running"); 190 191 // steal any collection lock that may or may not presents itself within param seconds 192 stealAnyCollectionLock(1); 193 switchToPane(GATHER_PANE); 194 195 // dummy tests 196 testGLIRunning(); 197 */ 198 // First tutorial 199 simpleHTML(); 200 201 } 179 202 180 203 // Selenium … … 185 208 abortListener.unregister(); // aborting assertJ-swing GUI tests 186 209 _driver.quit(); 187 } 210 //After exiting your application uninstall the no exit security manager 211 //org.assertj.swing.security.NoExitSecurityManagerInstaller.installNoExitSecurityManager().uninstall(); 212 } 213 214 /****************************** TUTORIAL FUNCTIONS *******************************/ 215 // Tutorial functions: regular methods called by JUnit at-Test methods in sequence 216 // to ensure sequential ordering of tests 217 public void simpleHTML() { 218 System.err.println("@@@ Tutorial 1: simple HTML"); 219 stealAnyCollectionLock(1); 220 switchToPane(GATHER_PANE); 221 changeUserMode("librarian"); 222 } 223 188 224 } -
gs3-extensions/testing/trunk/src/src/org/greenstone/gsdl3/testing/GSGUITestingUtil.java
r39016 r39018 113 113 // Gets a ref to the main window (FrameFixture) of a running GLI 114 114 public static FrameFixture getGLIApplicationWindow(Robot robotParam) { 115 return getGLIApplicationWindow(robotParam, -1); 116 } 117 118 // Gets a ref to the main window (FrameFixture) of a running GLI 119 public static FrameFixture getGLIApplicationWindow(Robot robotParam, int waitTime) { 115 120 GSGUITestingUtil.robot = robotParam; // store 116 121 117 122 // locate and set the internal FrameFixture member variable 'window' and return a handle to it 118 window = findFrame("GUIManager").using(robot); // GLI application JFrame's name is set to its classname, 'GUIManager' 123 if(waitTime <= 0) { 124 window = findFrame("GUIManager").using(robot); // GLI application JFrame's name is set to its classname, 'GUIManager' 125 } else { 126 window = findFrame("GUIManager").withTimeout(waitTime*SECOND).using(robot); 127 } 119 128 120 129 // https://joel-costigliola.github.io/assertj/swing/api/index.html?org/assertj/swing/launcher/ApplicationLauncher.html … … 295 304 //steal any lock 296 305 //PAUSE(3); 297 // See "Testing long duration tasks" at298 // https://joel-costigliola.github.io/assertj/assertj-swing-lookup.html299 300 /*301 try {302 DialogFixture lockfileDialog = findDialog("LockFileDialog").using(robot);//window.dialog("LockFileDialog");303 if(lockfileDialog != null) {304 lockfileDialog.click(); // bring to foreground in case JProgressBar hides it305 lockfileDialog.button("LockFileDialog.ok_button").click();306 }307 } catch(Exception e) {308 System.err.println("@@@@@@@@@@@@@ No lockfile dialog");309 }310 */311 306 stealAnyCollectionLock(1); 312 307 } … … 418 413 } 419 414 420 // Moving these working bits of code here, in case I can use them to right415 // Moving these working bits of code here, in case I can use them to write 421 416 // general get methods that make use of the GenericTypeMatcher method of accessing components 422 417 // See https://joel-costigliola.github.io/assertj/assertj-swing-lookup.html
Note:
See TracChangeset
for help on using the changeset viewer.