]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix running of all types of tests + generic cleanup
authorArtur Signell <artur@vaadin.com>
Tue, 3 Sep 2013 13:41:28 +0000 (16:41 +0300)
committerArtur Signell <artur@vaadin.com>
Tue, 3 Sep 2013 13:57:01 +0000 (16:57 +0300)
* All logic for running TB based tests is now in uitest
* Cleaning and server startup is now a responsibility of uitest/build.xml
* uitest/test.xml is responsible for running TB2 tests
* uitest/tb3test.xml is responsible for running TB3 tests
* AllIntegrationTests is now ServletIntegrationTests as a portlet integration tests still need to be added
* AllTB3Tests now find tests when run from Ant

Change-Id: I87b710827aaede93e36062842b514711d807408a

build.xml
uitest/build.xml
uitest/integration_tests.xml
uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
uitest/src/com/vaadin/tests/tb3/AllIntegrationTests.java [deleted file]
uitest/src/com/vaadin/tests/tb3/AllTB3Tests.java
uitest/src/com/vaadin/tests/tb3/ServletIntegrationTests.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/tb3/TB3Runner.java
uitest/src/com/vaadin/tests/tb3/TB3TestFinder.java
uitest/tb3test.xml [new file with mode: 0644]
uitest/test.xml

index 5f748d8f403d78896b26d5011bda100abb254bf5..bef7f7a2f39f539da2bb3aee0160c5d41bc03427 100644 (file)
--- a/build.xml
+++ b/build.xml
     <target name="test" depends="buildorder">
         <subant buildpathref="build-path" target="test" />
     </target>
+
     <target name="test-all" depends="buildorder">
         <property name="war.file" location="result/artifacts/${vaadin.version}/vaadin-uitest/vaadin-uitest-${vaadin.version}.war" />
+
         <parallel>
-            <sequential>
-                <!-- Sleep before running integration tests so testbench 
-                    tests have time to compile and start -->
-                <sleep minutes="4" />
-                <ant antfile="uitest/integration_tests.xml" target="integration-test-all" inheritall="false" inheritrefs="false">
-                    <property name="demo.war" value="${war.file}" />
-                </ant>
-            </sequential>
+            <!-- JUnit tests, can be run without a server -->
             <subant buildpathref="build-path" target="test" />
-            <ant antfile="uitest/test.xml" target="test-package">
+
+            <!-- Server deployment + TestBench tests  -->
+            <ant antfile="uitest/build.xml" target="test-testbench">
                 <property name="war.file" location="${war.file}" />
             </ant>
         </parallel>
index eb10f004d5850a46d20621da982be8fc321d22ee..af2d7cb1e1f616356006303fdb7d5b9da04a6823 100644 (file)
@@ -9,6 +9,7 @@
 
     <!-- global properties -->
     <property name="module.name" value="vaadin-uitest" />
+    <property name="uitest.dir" location="${vaadin.basedir}/uitest" />
     <property name="result.dir" value="result" />
     <property name="result.war" location="${result.dir}/lib/${module.name}-${vaadin.version}.war" />
 
         <echo>WHAT? No JUnit tests for ${module.name}!</echo>
     </target>
 
+    <target name="test-testbench" depends="clean-testbench-errors" description="Run all TestBench based tests, including server tests">
+        <parallel>
+            <daemons>
+                <!-- Start server -->
+                <ant antfile="${uitest.dir}/vaadin-server.xml" inheritall="true" inheritrefs="true" target="deploy-and-start" />
+            </daemons>
+            <sequential>
+                <!-- Server tests -->
+
+                <!-- Sleep before running integration tests so testbench 2 
+                        tests have time to compile and start -->
+                <sleep minutes="4" />
+                <ant antfile="${uitest.dir}/integration_tests.xml" target="integration-test-all" inheritall="false" inheritrefs="false">
+                    <property name="demo.war" value="${war.file}" />
+                </ant>
+            </sequential>
+            <sequential>
+                <!-- Wait for server to start -->
+                <ant antfile="${uitest.dir}/vaadin-server.xml" target="wait-for-startup" />
+
+                <!-- Run all different kinds of TestBench tests in parallel -->
+                <parallel>
+
+                    <!-- Legacy TestBench 2 tests -->
+                    <sequential>
+                        <ant antfile="${uitest.dir}/test.xml" target="tb2-tests" />
+                        <echo message="TestBench 2 tests complete" />
+                    </sequential>
+
+                    <!-- TestBench 3 tests -->
+                    <sequential>
+                        <ant antfile="${uitest.dir}/tb3test.xml" target="run-all-tb3-tests" inheritall="true" />
+                        <echo message="TestBench 3 tests complete" />
+                    </sequential>
+                </parallel>
+            </sequential>
+
+        </parallel>
+    </target>
+
+    <target name="clean-testbench-errors">
+        <fail unless="com.vaadin.testbench.screenshot.directory" message="Define screenshot directory using -Dcom.vaadin.testbench.screenshot.directory" />
+        <mkdir dir="${com.vaadin.testbench.screenshot.directory}/errors" />
+        <delete>
+            <fileset dir="${com.vaadin.testbench.screenshot.directory}/errors">
+                <include name="**/**.*" />
+            </fileset>
+        </delete>
+    </target>
+
 </project>
index 48b1656bcb0c8ebf48b6e1a6df078005ffd570e3..e4b7fefdfcaf80313ee1885f84374f56f52aff87 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 
-<project xmlns:antcontrib="antlib:net.sf.antcontrib" name="Vaadin Integration Tests" basedir="." default="integration-test-all">
+<project xmlns:antcontrib="antlib:net.sf.antcontrib" xmlns:ivy="antlib:org.apache.ivy.ant" name="Vaadin Integration Tests" basedir="." default="integration-test-all">
 
     <!-- Import common targets -->
     <import file="../common.xml" />
     <property name="user" value="${test.integration.user}" />
     <property name="passphrase" value="" />
 
+    <ivy:resolve file="ivy.xml" conf="build, build-provided" />
+    <ivy:cachepath pathid="classpath.tb3.lib" conf="build, build-provided" />
+    <path id="classpath.tb3">
+        <path refid="classpath.tb3.lib" />
+        <path location="result/classes" />
+    </path>
+
     <!-- Upload war to deploy to ssh host -->
     <target name="integration-test-upload-demo">
         <scp file="${demo.war}" todir="${user}@${test.integration.server}:integration-tests/servers/demo.war" keyfile="${sshkey.file}" passphrase="${passphrase}" />
     </target>
 
     <!-- Run basic integration test test -->
-    <target name="integration-test-servlet">
+    <target name="legacy-integration-test">
         <fail unless="html-test-files">html-test-files must be defined</fail>
         <pathconvert pathsep=" " property="testfiles" refid="html-test-files" />
         <subant target="run-tests" failonerror="false" antfile="test.xml">
         <sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} deploy-to-GAE" />
     </target>
 
+    <target name="run-tb3-servlet-test">
+        <antcall target="run-tb3-test" inheritall="true">
+            <param name="junit.test.suite" value="com.vaadin.tests.tb3.ServletIntegrationTests" />
+        </antcall>
+    </target>
+    <target name="run-tb3-test">
+        <fail unless="server-name" message="Server name must be defined in server-name" />
+        <fail unless="deployment.url" message="Deplyoment url must be defined in deployment.url" />
+        <fail unless="com.vaadin.testbench.screenshot.directory" message="Screenshot directory must be defined in com.vaadin.testbench.screenshot.directory" />
+
+        <junit printsummary="withOutAndErr" fork="yes">
+            <formatter usefile="false" type="plain" />
+            <classpath refid="classpath.tb3" />
+
+            <jvmarg value="-Dcom.vaadin.testbench.screenshot.directory=${com.vaadin.testbench.screenshot.directory}" />
+            <jvmarg value="-Ddeployment.url=${deployment.url}" />
+            <jvmarg value="-Dserver-name=${server-name}" />
+            <jvmarg value="-Djava.awt.headless=true" />
+            <test name="${junit.test.suite}" />
+        </junit>
+    </target>
 
     <target name="integration-test-tomcat7">
         <antcall target="run-generic-integration-test">
         <parallel>
             <antcontrib:trycatch property="tried">
                 <try>
-                    <!-- Still running GAE test from the old server which 
-                        requires its own lock -->
                     <echo message="Getting lock" />
                     <antcall target="integration-test-get-lock" />
                     <echo message="Got lock" />
             <antcall target="integration-test-tomcat6" />
             <antcall target="integration-test-tomcat7" />
             <antcall target="integration-test-websphere8" />
-
         </parallel>
 
     </target>
                 </fail>
 
                 <antcontrib:if>
-                    <isset property="html-test-files" />
+                    <isset property="testfiles" />
                     <antcontrib:then>
-                        <antcall target="integration-test-servlet">
+                        <echo>Starting legacy (TB2) test for ${target-server}</echo>
+                        <antcall target="legacy-integration-test">
                             <param name="server-name" value="${target-server}" />
                             <param name="deployment.url" value="http://${target-host}:${target-port}" />
                         </antcall>
                     </antcontrib:then>
                     <antcontrib:else>
-                        <echo>Starting test.xml</echo>
-                        <subant target="run-tb3-tests" failonerror="false" buildpath=".." genericantfile="test.xml">
-                            <property name="junit.test.suite" value="com.vaadin.tests.tb3.AllIntegrationTests" />
-                            
-                            <property name="com.vaadin.testbench.lib.dir" value="${com.vaadin.testbench.lib.dir}" />
-                            <property name="com.vaadin.testbench.tester.host" value="${com.vaadin.testbench.tester.host}" />
-                            <property name="com.vaadin.testbench.deployment.url" value="http://${target-host}:${target-port}" />
-                            <property name="server-name" value="${target-server}" />
-                        </subant>                            
+                        <echo>Starting TB3 test for ${target-server}</echo>
+                        <antcall target="run-tb3-servlet-test">
+                            <param name="server-name" value="${target-server}" />
+                            <param name="deployment.url" value="http://${target-host}:${target-port}" />
+                        </antcall>
                     </antcontrib:else>
                 </antcontrib:if>
 
index ca9ecd0d3eb60d2579a09c23f97e37e42996872b..44cd3a7d9613f8c52417f51a51e22f73bee028f1 100644 (file)
@@ -39,6 +39,7 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
             baseUrl = baseUrl.substring(0, baseUrl.length() - 1);\r
         }\r
 \r
+        System.out.println("Starting TB3 test for " + baseUrl + getPath());\r
         driver.get(baseUrl + getPath());\r
     }\r
 \r
diff --git a/uitest/src/com/vaadin/tests/tb3/AllIntegrationTests.java b/uitest/src/com/vaadin/tests/tb3/AllIntegrationTests.java
deleted file mode 100644 (file)
index b02c5f0..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2000-2013 Vaadin Ltd.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.vaadin.tests.tb3;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.model.InitializationError;
-
-import com.vaadin.tests.tb3.AllIntegrationTests.AllIntegrationTestsFinder;
-
-@RunWith(AllIntegrationTestsFinder.class)
-public class AllIntegrationTests {
-    public static class AllIntegrationTestsFinder extends TB3TestFinder {
-        public AllIntegrationTestsFinder(Class<?> klass)
-                throws InitializationError {
-            super(klass, AbstractTB3Test.class, "com.vaadin.tests.integration",
-                    new String[] {});
-        }
-    }
-}
index d2322d6f5833643b1a5183846d3e793905e073be..40e36f39768d5151db3629dd7bca148f327c72fa 100644 (file)
@@ -39,7 +39,7 @@ public class AllTB3Tests {
          * @throws InitializationError
          */
         public AllTestsFinder(Class<?> klass) throws InitializationError {
-            super(klass, AbstractTB3Test.class, "com.vaadin",
+            super(klass, AbstractTB3Test.class, "com.vaadin.tests",
                     new String[] { "com.vaadin.tests.integration" });
         }
 
diff --git a/uitest/src/com/vaadin/tests/tb3/ServletIntegrationTests.java b/uitest/src/com/vaadin/tests/tb3/ServletIntegrationTests.java
new file mode 100644 (file)
index 0000000..eb6ffe5
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.tests.tb3;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.model.InitializationError;
+
+import com.vaadin.tests.tb3.ServletIntegrationTests.ServletIntegrationTestsFinder;
+
+@RunWith(ServletIntegrationTestsFinder.class)
+public class ServletIntegrationTests {
+    public static class ServletIntegrationTestsFinder extends TB3TestFinder {
+        public ServletIntegrationTestsFinder(Class<?> klass)
+                throws InitializationError {
+            super(klass, AbstractTB3Test.class, "com.vaadin.tests.integration",
+                    new String[] {});
+        }
+    }
+}
index 2013d7b9ea9747e42da78ae77b0d8972242baaa6..dcfb8b69730d1732e4097da8f459bbb17984eabe 100644 (file)
@@ -178,14 +178,7 @@ public class TB3Runner extends BlockJUnit4ClassRunner {
                 browserName = "Opera";
             }
 
-            String format = browserName + capabilities.getVersion();
-
-            String serverName = System.getProperty("server-name");
-            if (serverName != null && !serverName.isEmpty()) {
-                format = serverName + "_" + format;
-            }
-
-            return format;
+            return browserName + capabilities.getVersion();
         }
     }
 }
index 9eba031a7d382ac76c5924ae848613aa265f840d..40425c6c0162f94e020a2a377c00cac01a0e41c4 100644 (file)
@@ -77,9 +77,9 @@ public class TB3TestFinder extends Suite {
      * @param suiteClasses
      * @throws InitializationError
      */
-    public TB3TestFinder(Class<?> klass, Class<AbstractTB3Test> baseClass,
-            String basePackage, String[] ignorePackages)
-            throws InitializationError {
+    public TB3TestFinder(Class<?> klass,
+            Class<? extends AbstractTB3Test> baseClass, String basePackage,
+            String[] ignorePackages) throws InitializationError {
         // Could consider reading settings from annoations on klass instead
         // creating sub classes
         super(klass, getAllTB3Tests(baseClass, basePackage, ignorePackages));
@@ -90,11 +90,11 @@ public class TB3TestFinder extends Suite {
      * @since
      * @return
      */
-    private static Class<?>[] getAllTB3Tests(Class<AbstractTB3Test> baseClass,
-            String basePackage, String[] ignorePackages) {
+    private static Class<?>[] getAllTB3Tests(
+            Class<? extends AbstractTB3Test> baseClass, String basePackage,
+            String[] ignorePackages) {
         try {
-            List<Class<? extends AbstractTB3Test>> l = findClasses(baseClass,
-                    basePackage, ignorePackages);
+            List<?> l = findClasses(baseClass, basePackage, ignorePackages);
             return l.toArray(new Class[] {});
         } catch (IOException e) {
             // TODO Auto-generated catch block
diff --git a/uitest/tb3test.xml b/uitest/tb3test.xml
new file mode 100644 (file)
index 0000000..5bd6e92
--- /dev/null
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<project name="tb3test" xmlns:antcontrib="antlib:net.sf.antcontrib" xmlns:ivy="antlib:org.apache.ivy.ant" basedir=".">
+
+    <dirname property="tb3test.dir" file="${ant.file.tb3test}" />
+
+       <ivy:resolve file="${tb3test.dir}/ivy.xml" conf="build, build-provided" />
+       <ivy:cachepath pathid="classpath.tb3.lib" conf="build, build-provided" />
+       <path id="classpath.tb3">
+               <path refid="classpath.tb3.lib" />
+               <path location="${tb3test.dir}/result/classes" />
+       </path>
+
+       <target name="run-all-tb3-tests" description="Run all the TB3 tests (except server tests) in the project">
+               <antcall target="run-tb3-suite">
+                       <param name="junit.test.suite" value="com.vaadin.tests.tb3.AllTB3Tests" />
+               </antcall>
+       </target>
+
+       <target name="run-tb3-suite">
+               <fail unless="junit.test.suite" message="Define suite to run using junit.test.suite" />
+               <fail unless="com.vaadin.testbench.screenshot.directory" message="Define screenshot directory using -Dcom.vaadin.testbench.screenshot.directory" />
+               <junit printsummary="withOutAndErr" fork="yes">
+                       <formatter usefile="false" type="plain" />
+                       <classpath refid="classpath.tb3" />
+
+                       <jvmarg value="-Dcom.vaadin.testbench.screenshot.directory=${com.vaadin.testbench.screenshot.directory}" />
+                       <jvmarg value="-Djava.awt.headless=true" />
+                       <test name="${junit.test.suite}" />
+               </junit>
+
+       </target>
+
+</project>
index 9b57b2d19f7bf6651caf39d7884b0227c83e4392..7a9ef717f4d46977d50d5a440b074213fcb3e99e 100644 (file)
@@ -39,7 +39,7 @@
 
     <!-- fileset containing all TestBench tests to run -->
     <fileset dir="${test.xml.dir}" id="html-test-files">
-        <include name="src/**/*.html" />
+        <include name="src/**/*Clipping*.html" />
         <exclude name="integration-testscripts/**/*.html" />
     </fileset>
 
         <fail unless="com.vaadin.testbench.deployment.url" message="The 'com.vaadin.testbench.deployment.url' property must be defined." />
     </target>
 
-    <target name="run-tests" depends="run-tb3-tests, run-tb2-tests">
-    </target>
-
-    <target name="run-tb3-tests">
-        <echo>Test.xml started</echo>
-
-        <property name="junit.test.suite" value="com.vaadin.tests.tb3.AllTB3Tests" />
-        <property name="com.vaadin.testbench.deployment.hostname" value="auto" />
-        <property name="com.vaadin.testbench.deployment.url" value="" />
-        <property name="server-name" value="" />
-
-        <ivy:resolve file="uitest/ivy.xml" conf="build, build-provided" />
-        <ivy:cachepath pathid="classpath.compile.dependencies" conf="build, build-provided" />
-
-        <junit printsummary="withOutAndErr" fork="yes">
-            <formatter usefile="false" type="plain" />
-
-            <classpath location="uitest/result/classes" />
-            <classpath refid="classpath.compile.dependencies" />
-
-            <jvmarg value="-Dcom.vaadin.testbench.tester.host=${com.vaadin.testbench.tester.host}" />
-            <jvmarg value="-Dcom.vaadin.testbench.deployment.hostname=${com.vaadin.testbench.deployment.hostname}" />
-
-            <!-- special parameters used when running integration tests -->
-            <jvmarg value="-Ddeployment.url=${com.vaadin.testbench.deployment.url}" />
-            <jvmarg value="-Dserver-name=${server-name}" />
-
-            <!-- Define where the reference screenshots and diff files are 
-                    saved -->
-            <jvmarg value="-Dcom.vaadin.testbench.screenshot.directory=${com.vaadin.testbench.screenshot.directory}" />
-            <!-- Resolution for screenshots -->
-            <jvmarg value="-Dcom.vaadin.testbench.screenshot.resolution=${com.vaadin.testbench.screenshot.resolution}" />
-            <jvmarg value="-Dcom.vaadin.testbench.debug=${com.vaadin.testbench.debug}" />
-            <jvmarg value="-Dcom.vaadin.testbench.screenshot.block.error=${com.vaadin.testbench.screenshot.block.error}" />
-
-            <jvmarg value="-Djava.awt.headless=true" />
-
-            <!-- true/false system arguments -->
-            <jvmarg value="-Dcom.vaadin.testbench.screenshot.softfail=${com.vaadin.testbench.screenshot.softfail}" />
-            <jvmarg value="-Dcom.vaadin.testbench.screenshot.reference.debug=${com.vaadin.testbench.screenshot.reference.debug}" />
-            <jvmarg value="-Dcom.vaadin.testbench.screenshot.cursor=${com.vaadin.testbench.screenshot.cursor}" />
-
-            <test name="${junit.test.suite}" />
-        </junit>
-    </target>
-
-    <target name="run-tb2-tests" depends="compile-tests">
+    <target name="run-tb2-tests" depends="check-parameters,compile-tests">
         <fileset dir="${test-output-dir}" id="tests-fileset">
             <include name="**/**.java" />
         </fileset>
     <!-- ================================================================== -->
 
     <!-- The default target. -->
-    <target name="run-and-clean-up" depends="check-parameters,remove-error-screens,run-tests" />
+    <target name="run-and-clean-up" depends="check-parameters,remove-error-screens,run-tb2-tests" />
 
-
-    <!-- Starts the server and runs all TestBench tests -->
-    <target name="test-package">
-        <fail unless="war.file" message="No 'war.file' parameter given." />
+    <!-- Runs all TestBench 2 tests -->
+    <target name="tb2-tests">
         <property name="test-output-dir" location="${test.xml.dir}/result/testbench-junit-classes" />
         <property name="retries" value="2" />
 
         <property name="com.vaadin.testbench.screenshot.block.error" value="0.025" />
         <property name="com.vaadin.testbench.debug" value="false" />
 
-        <parallel>
-            <daemons>
-                <ant antfile="${test.xml.dir}/vaadin-server.xml" inheritall="true" inheritrefs="true" target="deploy-and-start" />
-            </daemons>
-            <sequential>
-                <ant antfile="${test.xml.dir}/vaadin-server.xml" target="wait-for-startup" />
-                <antcall inheritall="true" inheritrefs="true" target="run-and-clean-up" />
-                <echo message="All TestBench tests have been run" />
-            </sequential>
-        </parallel>
+        <antcall inheritall="true" inheritrefs="true" target="run-tb2-tests" />
     </target>
 </project>