You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2011/08/08 01:31:18 UTC
svn commit: r1154798 - in
/tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test:
ErrorReporterImpl.java SeleniumTestCase.java
Author: hlship
Date: Sun Aug 7 23:31:18 2011
New Revision: 1154798
URL: http://svn.apache.org/viewvc?rev=1154798&view=rev
Log:
Enhance integration tests to display a list of output screen capture files at the end of the test execution
Modified:
tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/ErrorReporterImpl.java
tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java
Modified: tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/ErrorReporterImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/ErrorReporterImpl.java?rev=1154798&r1=1154797&r2=1154798&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/ErrorReporterImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/ErrorReporterImpl.java Sun Aug 7 23:31:18 2011
@@ -14,17 +14,18 @@
package org.apache.tapestry5.test;
+import com.thoughtworks.selenium.CommandProcessor;
+import org.testng.ITestContext;
+
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.lang.reflect.Method;
+import java.util.ArrayList;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
-import org.testng.ITestContext;
-
-import com.thoughtworks.selenium.CommandProcessor;
-
public class ErrorReporterImpl implements ErrorReporter
{
private final CommandProcessor commandProcessor;
@@ -35,16 +36,40 @@ public class ErrorReporterImpl implement
private final Set<String> previousNames = new HashSet<String>();
+ private final List<File> outputPaths = new ArrayList<File>();
+
public ErrorReporterImpl(CommandProcessor commandProcessor, ITestContext testContext)
{
this.commandProcessor = commandProcessor;
this.testContext = testContext;
}
+ public void writeOutputPaths()
+ {
+ if (outputPaths.isEmpty())
+ {
+ return;
+ }
+
+ System.err.println("Page captures written to:");
+
+ for (File file : outputPaths)
+ {
+ try
+ {
+ System.err.println(" " + file.getCanonicalPath());
+ } catch (IOException e)
+ {
+ // Ignored. Like, what's going to happen?
+ }
+ }
+
+ }
+
public void writeErrorReport()
{
String htmlSource = commandProcessor.getString("getHtmlSource", new String[]
- {});
+ {});
File dir = new File(testContext.getOutputDirectory());
@@ -58,13 +83,12 @@ public class ErrorReporterImpl implement
if (previousNames.contains(baseFileName))
{
baseFileName += "-" + uid++;
- }
- else
+ } else
{
previousNames.add(baseFileName);
}
- File report = new File(dir, baseFileName + "-page-content.html");
+ File report = new File(dir, baseFileName + ".html");
System.err.println("Writing current page's HTML source to: " + report);
@@ -74,19 +98,22 @@ public class ErrorReporterImpl implement
fw.write(htmlSource);
+ outputPaths.add(report);
+
fw.close();
- }
- catch (IOException ex)
+ } catch (IOException ex)
{
// Ignore.
}
- File capture = new File(dir, baseFileName + "-screen-capture.png");
+ File capture = new File(dir, baseFileName + ".png");
System.err.println("Writing current page screenshot to: " + capture);
commandProcessor.doCommand("captureEntirePageScreenshot", new String[]
- { capture.getAbsolutePath(), "background=white" });
+ {capture.getAbsolutePath(), "background=white"});
+
+ outputPaths.add(capture);
}
}
Modified: tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java?rev=1154798&r1=1154797&r2=1154798&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java (original)
+++ tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java Sun Aug 7 23:31:18 2011
@@ -180,7 +180,7 @@ public abstract class SeleniumTestCase e
CommandProcessor httpCommandProcessor = new HttpCommandProcessor("localhost",
RemoteControlConfiguration.DEFAULT_PORT, browserStartCommand, baseURL);
- ErrorReporter errorReporter = new ErrorReporterImpl(httpCommandProcessor, testContext);
+ final ErrorReporterImpl errorReporter = new ErrorReporterImpl(httpCommandProcessor, testContext);
ErrorReportingCommandProcessor commandProcessor = new ErrorReportingCommandProcessor(httpCommandProcessor,
errorReporter);
@@ -203,6 +203,13 @@ public abstract class SeleniumTestCase e
selenium.stop();
seleniumServer.stop();
stopWebServer.run();
+
+ // Output, at the end of the Test, any html capture or screen shots (this makes it much easier
+ // to locate them at the end of the run; there's such a variance on where they end up based
+ // on whether the tests are running from inside an IDE or via one of the command line
+ // builds.
+
+ errorReporter.writeOutputPaths();
}
finally
{