[seam-commits] Seam SVN: r11513 - in branches/enterprise/JBPAPP_5_0/src/test/ftest: src/main/org/jboss/seam/example/common/test/selenium and 1 other directory.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Thu Sep 24 09:03:53 EDT 2009


Author: mgencur at redhat.com
Date: 2009-09-24 09:03:52 -0400 (Thu, 24 Sep 2009)
New Revision: 11513

Added:
   branches/enterprise/JBPAPP_5_0/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeleniumFunctionalTestListener.java
Modified:
   branches/enterprise/JBPAPP_5_0/src/test/ftest/examples/build.xml
   branches/enterprise/JBPAPP_5_0/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSeleniumTest.java
Log:
JBPAPP-2849 Added functionality for making screenshots and storing html source of seam examples tested by functional tests that fail

Modified: branches/enterprise/JBPAPP_5_0/src/test/ftest/examples/build.xml
===================================================================
--- branches/enterprise/JBPAPP_5_0/src/test/ftest/examples/build.xml	2009-09-24 12:33:21 UTC (rev 11512)
+++ branches/enterprise/JBPAPP_5_0/src/test/ftest/examples/build.xml	2009-09-24 13:03:52 UTC (rev 11513)
@@ -44,6 +44,7 @@
 	<!-- default context paths -->
 	<property name="jboss5.context.path" value="/seam-${example.name}" />
 
+	<property name="functional.listener" value="org.jboss.seam.example.common.test.selenium.SeleniumFunctionalTestListener"/>
 
 	<!-- common path setup -->
 	<path id="classpath.build">
@@ -95,7 +96,7 @@
 		<mkdir dir="${test.output.dir}" />
 
 		<!-- execute testng tests -->
-		<testng haltonfailure="false" outputdir="${test.output.dir}" classpathref="classpath.test">
+		<testng haltonfailure="false" outputdir="${test.output.dir}" classpathref="classpath.test" listener="${functional.listener}">
 			<xmlfileset file="${container}.xml" />
 			<sysproperty key="selenium.server.port" value="${selenium.server.port}" />
 			<sysproperty key="selenium.host" value="${selenium.host}" />
@@ -106,6 +107,7 @@
 			<sysproperty key="example.context.path" value="${context.path}" />
 			<sysproperty key="openid.account" value="${openid.account}" />
 			<sysproperty key="openid.password" value="${openid.password}" />
+			<sysproperty key="seam.dir" value="${seam.dir}" />
 		</testng>
 	</target>
 

Modified: branches/enterprise/JBPAPP_5_0/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSeleniumTest.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSeleniumTest.java	2009-09-24 12:33:21 UTC (rev 11512)
+++ branches/enterprise/JBPAPP_5_0/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSeleniumTest.java	2009-09-24 13:03:52 UTC (rev 11513)
@@ -50,15 +50,20 @@
     protected String CONTEXT_PATH = "";
     private static Properties properties = new Properties();
     private static boolean propertiesLoaded = false;
+    
+    protected static String SEAM_DIR;
+    protected static String APP_NAME;
+    protected static String OUTPUT_DIR;
+    
+    //protected SeamSelenium
+    public static SeamSelenium browser;
 
-    protected SeamSelenium browser;
-
     @BeforeClass
     @Parameters( { "selenium.host", "selenium.server.port", "selenium.browser",
             "selenium.browser.url", "selenium.speed", "selenium.timeout",
-            "PROPERTY_FILE", "example.context.path" })
+            "PROPERTY_FILE", "example.context.path", "seam.dir" })
     public void setParameters(String host, String port, String browser,
-            String browserUrl, String speed, String timeout, String propertyFile, @Optional("") String contextPath) {
+            String browserUrl, String speed, String timeout, String propertyFile, @Optional("") String contextPath, String seamDir) {
         HOST = host;
         PORT = Integer.parseInt(port);
         BROWSER = browser;
@@ -66,7 +71,9 @@
         SPEED = speed;
         TIMEOUT = timeout;
         PROPERTY_FILE = propertyFile;
-        CONTEXT_PATH = contextPath;
+        CONTEXT_PATH = APP_NAME = contextPath;
+        SEAM_DIR = seamDir;
+        OUTPUT_DIR = SEAM_DIR + "/test-output/functional-framework";
     }
 
     @BeforeMethod
@@ -76,7 +83,8 @@
 
     @AfterMethod
     public void tearDown() {
-        stopBrowser();
+       /*browser is being closed from SeleniumFunctionalTestListener class*/ 
+       //stopBrowser();
     }
 
     public SeamSelenium startBrowser() {

Added: branches/enterprise/JBPAPP_5_0/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeleniumFunctionalTestListener.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeleniumFunctionalTestListener.java	                        (rev 0)
+++ branches/enterprise/JBPAPP_5_0/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeleniumFunctionalTestListener.java	2009-09-24 13:03:52 UTC (rev 11513)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.seam.example.common.test.selenium;
+
+import org.testng.ITestContext;
+import org.testng.ITestListener;
+import org.testng.ITestResult;
+
+/**
+ * This listener class is used for capturing snapshot of running web application and storing 
+ * html source of the html file.
+ * 
+ * @author Martin Gencur
+ *
+ */
+public class SeleniumFunctionalTestListener extends SeamSeleniumTest implements ITestListener
+{
+   
+   public void onFinish(ITestContext arg0)
+   {
+   }
+   
+   public void onStart(ITestContext arg0)
+   {
+   }
+   
+   public void onTestFailedButWithinSuccessPercentage(ITestResult arg0)
+   {
+   }
+   
+   public void onTestFailure(ITestResult arg0)
+   {
+      String logPath = OUTPUT_DIR + APP_NAME + "/" + arg0.getName();
+      try {
+         SeamSeleniumTest.browser.captureScreenshot(logPath + ".png");
+         SeamSeleniumTest.browser.logHTMLContext(logPath + ".html");
+      } catch (Exception e) {         
+      } finally {
+         stopBrowser();   
+      }      
+   }
+   
+   public void onTestSkipped(ITestResult arg0)
+   {
+      stopBrowser();
+   }
+   
+   public void onTestStart(ITestResult arg0)
+   {
+   }
+   
+   public void onTestSuccess(ITestResult arg0)
+   {
+      stopBrowser();
+   }   
+}
\ No newline at end of file



More information about the seam-commits mailing list