summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2013-10-14 22:05:40 +0300
committerArtur Signell <artur@vaadin.com>2013-10-15 17:11:16 +0300
commitf9ea9b31d4b97714fefeb7970600c1058f794e5e (patch)
tree5f26f7afdabe7f23f70336cfa832b19ef7d6f97f /uitest
parentce89a75620078677d118769a74d5b2cf778c9792 (diff)
downloadvaadin-framework-f9ea9b31d4b97714fefeb7970600c1058f794e5e.tar.gz
vaadin-framework-f9ea9b31d4b97714fefeb7970600c1058f794e5e.zip
Allow running tests locally by overriding runLocally() (#12786)
Uses Firefox either from path or from the location given using firefox.path in /work/run-eclipse-run-selected-test.properties Change-Id: I29faa94cac4c978792a8fab9db338048553d166a
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java22
-rw-r--r--uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java25
-rw-r--r--uitest/src/com/vaadin/tests/tb3/TB3Runner.java12
3 files changed, 57 insertions, 2 deletions
diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
index e831a4f15f..7584f36e28 100644
--- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
+++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
@@ -104,6 +104,10 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
* If something goes wrong
*/
protected void setupDriver() throws Exception {
+ if (runLocally()) {
+ setupLocalDriver();
+ return;
+ }
DesiredCapabilities capabilities = getDesiredCapabilities();
WebDriver dr = TestBench.createDriver(new RemoteWebDriver(new URL(
@@ -127,6 +131,23 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
}
/**
+ * Override and return true to run the test locally. This method is only to
+ * be used for developing tests.
+ *
+ * @return true to run the test on a local browser, false to use the hub
+ */
+ public boolean runLocally() {
+ return false;
+ }
+
+ /**
+ * Creates a {@link WebDriver} instance used for running the test locally
+ * for debug purposes. Used only when {@link #runLocally()} is overridden to
+ * return true;
+ */
+ protected abstract void setupLocalDriver();
+
+ /**
* Opens the given test (defined by {@link #getTestUrl(boolean, boolean)},
* optionally with debug window and/or push
*
@@ -792,4 +813,5 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
// Do nothing by default
}
+
}
diff --git a/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java b/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java
index 09615f0b2e..a2922af28f 100644
--- a/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java
+++ b/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java
@@ -25,6 +25,12 @@ import java.net.SocketException;
import java.util.Enumeration;
import java.util.Properties;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.firefox.FirefoxBinary;
+import org.openqa.selenium.firefox.FirefoxDriver;
+
+import com.vaadin.testbench.TestBench;
+
/**
* Provides values for parameters which depend on where the test is run.
* Parameters should be configured in work/eclipse-run-selected-test.properties.
@@ -132,4 +138,23 @@ public abstract class PrivateTB3Configuration extends ScreenshotTB3Test {
"No compatible (192.168.*) ip address found.");
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.tb3.AbstractTB3Test#setupLocalDriver()
+ */
+ @Override
+ protected void setupLocalDriver() {
+ String firefoxPath = getProperty("firefox.path");
+ WebDriver driver;
+ if (firefoxPath != null) {
+ driver = new FirefoxDriver(
+ new FirefoxBinary(new File(firefoxPath)), null);
+ } else {
+ driver = new FirefoxDriver();
+ }
+ setDriver(TestBench.createDriver(driver));
+ setDesiredCapabilities(BrowserUtil
+ .firefox(MultiBrowserTest.TESTED_FIREFOX_VERSION));
+ }
}
diff --git a/uitest/src/com/vaadin/tests/tb3/TB3Runner.java b/uitest/src/com/vaadin/tests/tb3/TB3Runner.java
index b612b17caa..4e084ab0ed 100644
--- a/uitest/src/com/vaadin/tests/tb3/TB3Runner.java
+++ b/uitest/src/com/vaadin/tests/tb3/TB3Runner.java
@@ -17,6 +17,8 @@
package com.vaadin.tests.tb3;
import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.ExecutorService;
@@ -72,8 +74,14 @@ public class TB3Runner extends BlockJUnit4ClassRunner {
try {
AbstractTB3Test testClassInstance = (AbstractTB3Test) getTestClass()
.getOnlyConstructor().newInstance();
- for (DesiredCapabilities capabilities : testClassInstance
- .getBrowsersToTest()) {
+ Collection<DesiredCapabilities> desiredCapabilites = testClassInstance
+ .getBrowsersToTest();
+ if (testClassInstance.runLocally()) {
+ desiredCapabilites = new ArrayList<DesiredCapabilities>();
+ desiredCapabilites.add(BrowserUtil
+ .firefox(MultiBrowserTest.TESTED_FIREFOX_VERSION));
+ }
+ for (DesiredCapabilities capabilities : desiredCapabilites) {
// Find any methods marked with @Test.
for (FrameworkMethod m : getTestClass().getAnnotatedMethods(