DESCRIPTION

Create an automatic UI test for the Git Import Wizard

Things like dialogs and such require a different approach. The
strategy is to use SWTBot for runnings UI-oriented tests.

Change-Id: Ibc4c7a5ad6d9747fceb516c02d96dfc2b09d3b5a
Signed-off-by: Juliet Cantu xxx@xxx.xxx


COMMENTS

author: Juliet Cantu
date: 2009-12-10 21:23:40.000000000

Patch Set 1: No score; IP review completed



-------------------------------------
author: Ace Duncan
date: 2009-12-11 12:43:51.000000000

Patch Set 1: I would prefer that you didn't submit this; No score

What is the reason to use net.sf.swtbot.* and not org.eclipse.swtbot.*? With these changes I was able to run UI tests, but was blocked by 'No tests found' error.

Line:7, org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/sharing/GitCloneWizardTest.java -> Why net.sf.swtbot was used and not org.eclipse.swtbot.*?

--- INDEX:/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/sharing/GitCloneWizardTest.java
+++ WORKDIR:/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/sharing/GitCloneWizardTest.java
@@ -4,14 xxx@xxx.xxx
 import java.io.FileOutputStream;
 import java.io.IOException;
 
-import net.sf.swtbot.eclipse.finder.SWTBotEclipseTestCase;
-import net.sf.swtbot.wait.Conditions;
-import net.sf.swtbot.widgets.SWTBotShell;
-import net.sf.swtbot.widgets.SWTBotTree;
-
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.jgit.lib.Repository;
+import org.eclipse.swtbot.eclipse.finder.SWTBotEclipseTestCase;
+import org.eclipse.swtbot.swt.finder.waits.Conditions;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;

Line:28, org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/sharing/GitCloneWizardTest.java -> The same issue as in http://egit.eclipse.org/r/133:

org.eclipse.egit.ui--All tests
org.eclipse.egit.ui.internal.sharing.GitCloneWizardTest
warning(junit.framework.TestSuite$1)
junit.framework.AssertionFailedError: No tests found in org.eclipse.egit.ui.internal.sharing.GitCloneWizardTest
	at junit.framework.Assert.fail(Assert.java:47)
	at junit.framework.TestSuite$1.runTest(TestSuite.java:90)
	at junit.framework.TestCase.runBare(TestCase.java:130)
	at junit.framework.TestResult$1.protect(TestResult.java:106)

Line:9, org.eclipse.egit.ui.test/META-INF/MANIFEST.MF -> The same net.sf.swtbot vs o.e.swtbot:

diff --git a/org.eclipse.egit.ui.test/META-INF/MANIFEST.MF b/org.eclipse.egit.ui.test/META-INF/MANIFEST.MF
index e3554e4..2670d4c 100644
--- a/org.eclipse.egit.ui.test/META-INF/MANIFEST.MF
+++ b/org.eclipse.egit.ui.test/META-INF/MANIFEST.MF
@@ -6,14 xxx@xxx.xxx Bundle-Version: 0.6.0.qualifier
 Bundle-Activator: org.eclipse.egit.ui.test.Activator
 Require-Bundle: org.eclipse.core.runtime,
  org.eclipse.egit.ui;bundle-version="0.6.0",
- net.sf.swtbot.eclipse.finder;bundle-version="2.0.0",
- net.sf.swtbot.eclipse.spy;bundle-version="2.0.0",
- net.sf.swtbot.eclipse.ui;bundle-version="2.0.0",
- net.sf.swtbot.finder;bundle-version="2.0.0",
+ org.eclipse.swtbot.eclipse.finder;bundle-version="2.0.0",
+ org.eclipse.swtbot.eclipse.spy;bundle-version="2.0.0",
+ org.eclipse.swtbot.eclipse.ui;bundle-version="2.0.0",
+ org.eclipse.swtbot.swt.finder;bundle-version="2.0.0",
  org.eclipse.swt;bundle-version="3.4.0",
  org.eclipse.ui;bundle-version="3.4.0",
  org.eclipse.core.resources;bundle-version="3.4.0",
  org.eclipse.jgit;bundle-version="0.6.0",
- org.apache.log4j;bundle-version="1.2.13"
+ org.apache.log4j;bundle-version="1.2.13",
+ org.hamcrest;bundle-version="1.1.0"
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: J2SE-1.5

-------------------------------------
author: Douglas Trujillo
date: 2010-01-08 15:00:54.000000000

Patch Set 1: No score; No score

I tried on Eclipse 3.5.1 on Windows XP using SWTBot 2.0.0.433-dev-e35 and face a lot of problems:
* as mentioned by Mykola I also only find the SWTBot plugins under org.eclipse -> needed to switch dependencies
* the tests seem to fail randomly, seems to be some threading or timing issue, when I capture a screenshot before each assert most tests succeed ?!?
* some more comments inline

Line:28, org.eclipse.egit.ui.test/org.eclipse.egit.ui--All tests.launch -> I had to switch to JUnit 4 and annotate classes otherwise SWTBot doesn't find the test cases (probably because JUnit 3 only find tests which directly inherit from TestCase)

Line:40, org.eclipse.egit.ui.test/org.eclipse.egit.ui--All tests.launch -> according to SWTBot documentation [1] tests should not run in UI thread hence add:

<booleanAttribute key="run_in_ui_thread" value="false"/>

In order to make it work on German system I had to pass US keyboard layout as VM parameter, in order to play with timing parameters I added the other 2 parameters :

<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dorg.eclipse.swtbot.playback.poll.delay=500 -Dorg.eclipse.swtbot.playback.delay=0 -Dorg.eclipse.swtbot.keyboard.layout=EN_US"/>

[1] http://wiki.eclipse.org/SWTBot/FAQ#Why_do_tests_run_on_a_non-UI_thread.3F

Line:28, org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/sharing/GitCloneWizardTest.java -> I prepended 

@RunWith(SWTBotJunit4ClassRunner.class)

to make this run under JUnit 4

Line:39, org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/sharing/GitCloneWizardTest.java -> annotate xxx@xxx.xxx
to mark it as a JUnit 4 test, same for all other tests

Line:40, org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/sharing/GitCloneWizardTest.java -> I had to prepend 

bot.perspectiveByLabel("Java").activate();

in order to switch to Java perspective otherwise package explorer isn't found

view() is deprecated hence better use 

bot.viewByTitle("Package Explorer").show();

Line:49, org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/sharing/GitCloneWizardTest.java -> the section until this line is repeated in all test cases it should better be factored out into a helper method

-------------------------------------
author: Douglas Trujillo
date: 2010-01-08 15:01:07.000000000

Patch Set 1: I would prefer that you didn't submit this



-------------------------------------
author: Ace Duncan
date: 2010-01-08 20:06:57.000000000

MISMATCHED INLINE COMMENT
Line:28, org.eclipse.egit.ui.test/org.eclipse.egit.ui--All tests.launch -> IIRC there are some issues when JUnit3 and JUnit4 bundles available in the same time. See http://wiki.eclipse.org/Eclipse/Testing/JUnit4_Changes#Moving_to_JUnit4 for more info on migrating to JUnit4.

-------------------------------------
author: Juliet Cantu
date: 2010-01-08 15:59:44.000000000

MISMATCHED INLINE COMMENT
Line:28, org.eclipse.egit.ui.test/org.eclipse.egit.ui--All tests.launch -> Probably sine you switched to another swtbot

-------------------------------------
author: Juliet Cantu
date: 2010-01-09 23:01:59.000000000

MISMATCHED INLINE COMMENT
Line:231, org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/sharing/GitCloneWizardTest.java -> A difference between SWTBot or Eclipse versions

-------------------------------------
author: Douglas Trujillo
date: 2010-01-09 00:18:59.000000000

MISMATCHED INLINE COMMENT
Line:231, org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/sharing/GitCloneWizardTest.java -> Here I had to add
    
  bot.textWithLabel("URI:").pressShortcut(Keystrokes.END);

in order to append the X at the end of the URI

-------------------------------------
author: Juliet Cantu
date: 2010-01-09 23:01:59.000000000

MISMATCHED INLINE COMMENT
Line:405, org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/sharing/GitCloneWizardTest.java -> The behaviour here is also to switch to the branch page, which is disabled until the error occurs after about five minutes (something I'd like to shorten somhoew).

-------------------------------------
author: Douglas Trujillo
date: 2010-01-09 00:18:59.000000000

MISMATCHED INLINE COMMENT
Line:405, org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/sharing/GitCloneWizardTest.java -> Here EGit behaves differently than this test expects, instead of displaying the expected error message it proceeds to the next wizard page ("Select branches to clone from remote repository.").

msysgit CLI behaves similarily when trying to clone from this URL, it initializes an empty repository and then hangs forever.

-------------------------------------
author: Juliet Cantu
date: 2010-01-09 23:01:59.000000000

MISMATCHED INLINE COMMENT
Line:436, org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/sharing/GitCloneWizardTest.java -> No popup here. I wonder what is going on.
This timeout takes a long time on my machine.

-------------------------------------
author: Douglas Trujillo
date: 2010-01-09 00:18:59.000000000

MISMATCHED INLINE COMMENT
Line:436, org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/sharing/GitCloneWizardTest.java -> EGit behaves differently than this test expects, when timeout is reached it doesn't display the error on the wizard page but raises an extra error popup saying

Transport error  Reason: 
git://www.example.com/EGIT: connection timeout: connect

hence this assert fails consistently.

-------------------------------------
author: Juliet Cantu
date: 2010-01-08 21:59:19.000000000

MISMATCHED INLINE COMMENT
Line:6, org.eclipse.egit.ui.test/META-INF/MANIFEST.MF -> The activator is something I got from a tutorial on unit testing Eclipse plugins. Maybe that's obsolete now?

-------------------------------------
author: Ace Duncan
date: 2010-01-08 20:06:57.000000000

MISMATCHED INLINE COMMENT
Line:6, org.eclipse.egit.ui.test/META-INF/MANIFEST.MF -> Do we really need an activator?

-------------------------------------
