[seam-commits] Seam SVN: r11511 - in branches/community/Seam_2_2/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 08:10:40 EDT 2009
Author: mgencur at redhat.com
Date: 2009-09-24 08:10:40 -0400 (Thu, 24 Sep 2009)
New Revision: 11511
Added:
branches/community/Seam_2_2/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeleniumFunctionalTestListener.java
Modified:
branches/community/Seam_2_2/src/test/ftest/examples/build.xml
branches/community/Seam_2_2/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSeleniumTest.java
Log:
JBSEAM-4423 Added classes for capturing screenshots and html sources of web pages of seam examples when functional tests fail
Modified: branches/community/Seam_2_2/src/test/ftest/examples/build.xml
===================================================================
--- branches/community/Seam_2_2/src/test/ftest/examples/build.xml 2009-09-24 03:53:03 UTC (rev 11510)
+++ branches/community/Seam_2_2/src/test/ftest/examples/build.xml 2009-09-24 12:10:40 UTC (rev 11511)
@@ -52,6 +52,8 @@
<property name="jboss5.context.path" value="${jboss4.context.path}" />
<property name="jboss-embedded.context.path" value="/jboss-seam-${example.name}" />
<property name="tomcat6.context.path" value="${jboss-embedded.context.path}" />
+
+ <property name="functional.listener" value="org.jboss.seam.example.common.test.selenium.SeleniumFunctionalTestListener"/>
<!-- common path setup -->
@@ -109,7 +111,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}" />
@@ -120,6 +122,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/community/Seam_2_2/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSeleniumTest.java
===================================================================
--- branches/community/Seam_2_2/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSeleniumTest.java 2009-09-24 03:53:03 UTC (rev 11510)
+++ branches/community/Seam_2_2/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSeleniumTest.java 2009-09-24 12:10:40 UTC (rev 11511)
@@ -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/community/Seam_2_2/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeleniumFunctionalTestListener.java
===================================================================
--- branches/community/Seam_2_2/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeleniumFunctionalTestListener.java (rev 0)
+++ branches/community/Seam_2_2/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeleniumFunctionalTestListener.java 2009-09-24 12:10:40 UTC (rev 11511)
@@ -0,0 +1,71 @@
+/*
+ * 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();
+ SeamSeleniumTest.browser.captureScreenshot(logPath + ".png");
+ SeamSeleniumTest.browser.logHTMLContext(logPath + ".html");
+ 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