]> source.dussan.org Git - vaadin-framework.git/commitdiff
Disallow RunLocally annotation in framework tests. Fix NPE for
authorTeemu Suo-Anttila <teemusa@vaadin.com>
Mon, 9 Mar 2015 11:35:32 +0000 (13:35 +0200)
committerVaadin Code Review <review@vaadin.com>
Wed, 8 Apr 2015 14:23:00 +0000 (14:23 +0000)
screenshots.

Change-Id: I72793d85dfaba41aefa5370331c1ae81348607e9

uitest/eclipse-run-selected-test.properties
uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java
uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java

index f8fb0a8c14c30f84d981a49d21a890c36ff4875b..535885f8779a6f4d6706071216c6674d7a996abe 100644 (file)
@@ -22,8 +22,13 @@ com.vaadin.testbench.screenshot.directory=<enter the full path to the screenshot
 ;
 
 ; Simulates @RunLocally with the given value on all test classes without a @RunLocally annotation.
+; Use simple browser name (phantomjs, chrome, firefox, ie8, ie9, ie10, ie11)
 ; com.vaadin.testbench.runLocally=firefox
 
+; By default using @RunLocally annotation in Framework tests is not allowed. 
+; Running tests locally can be done with com.vaadin.testbench.runLocally parameter above. 
+; Uncomment the following line if you want to be able to use @RunLocally annotation
+; com.vaadin.testbench.allowRunLocally=true
 
 ;
 ; For only TestBench 2
index a95def5983684b8ce50b74d029cb02234cfb9dce..2d032ecd9eb8c280ac52d53399677aedf2b087fa 100644 (file)
@@ -142,7 +142,6 @@ public abstract class AbstractTB3Test extends ParallelTest {
         } catch (UnsupportedOperationException e) {
             // Opera does not support this...
         }
-
     }
 
     /**
@@ -244,7 +243,7 @@ public abstract class AbstractTB3Test extends ParallelTest {
     private void openTestURL(Class<?> uiClass, Set<String> parameters) {
         String url = getTestURL(uiClass);
 
-        if(isDebug()) {
+        if (isDebug()) {
             parameters.add("debug");
         }
 
index d0134a4feb329d8e27e77020cc1584784b7a7443..dce725b7c005fbf817ce6e940b9c8fffc216b6cb 100644 (file)
@@ -25,9 +25,11 @@ import java.net.SocketException;
 import java.util.Enumeration;
 import java.util.Properties;
 
+import org.junit.Assert;
 import org.openqa.selenium.remote.DesiredCapabilities;
 
 import com.vaadin.testbench.annotations.BrowserFactory;
+import com.vaadin.testbench.annotations.RunLocally;
 import com.vaadin.testbench.annotations.RunOnHub;
 import com.vaadin.testbench.parallel.Browser;
 
@@ -45,8 +47,9 @@ public abstract class PrivateTB3Configuration extends ScreenshotTB3Test {
      * 
      */
     public static final String SCREENSHOT_DIRECTORY = "com.vaadin.testbench.screenshot.directory";
-    private static final String RUN_LOCALLY_PROPERTY = "com.vaadin.testbench.runLocally";
     private static final String HOSTNAME_PROPERTY = "com.vaadin.testbench.deployment.hostname";
+    private static final String RUN_LOCALLY_PROPERTY = "com.vaadin.testbench.runLocally";
+    private static final String ALLOW_RUN_LOCALLY_PROPERTY = "com.vaadin.testbench.allowRunLocally";
     private static final String PORT_PROPERTY = "com.vaadin.testbench.deployment.port";
     private static final String DEPLOYMENT_PROPERTY = "com.vaadin.testbench.deployment.url";
     private static final String HUB_URL = "com.vaadin.testbench.hub.url";
@@ -77,6 +80,18 @@ public abstract class PrivateTB3Configuration extends ScreenshotTB3Test {
         }
     }
 
+    @Override
+    public void setup() throws Exception {
+        String allowRunLocally = getProperty(ALLOW_RUN_LOCALLY_PROPERTY);
+        if ((allowRunLocally == null || !allowRunLocally.equals("" + true))
+                && getClass().getAnnotation(RunLocally.class) != null) {
+            Assert.fail("@RunLocally annotation is not allowed by default in framework tests. "
+                    + "See file uitest/eclipse-run-selected-test.properties for more information.");
+        }
+
+        super.setup();
+    }
+
     private static DesiredCapabilities getRunLocallyCapabilities() {
         Browser localBrowser;
         try {
index f401e0613b2bf18f1621adfa2522923f6ecce3bf..e059dea78db2a062121606852a06bd6bad405cf1 100644 (file)
@@ -340,7 +340,7 @@ public abstract class ScreenshotTB3Test extends AbstractTB3Test {
      */
     @After
     public void checkCompareFailures() throws IOException {
-        if (!screenshotFailures.isEmpty()) {
+        if (screenshotFailures != null && !screenshotFailures.isEmpty()) {
             throw new IOException(
                     "The following screenshots did not match the reference: "
                             + screenshotFailures.toString());