You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by br...@apache.org on 2012/08/15 08:02:52 UTC
svn commit: r1373222 -
/continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/listener/CaptureScreenShotsListener.java
Author: brett
Date: Wed Aug 15 06:02:52 2012
New Revision: 1373222
URL: http://svn.apache.org/viewvc?rev=1373222&view=rev
Log:
capture screen and trace even in an unusal location
Modified:
continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/listener/CaptureScreenShotsListener.java
Modified: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/listener/CaptureScreenShotsListener.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/listener/CaptureScreenShotsListener.java?rev=1373222&r1=1373221&r2=1373222&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/listener/CaptureScreenShotsListener.java (original)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/listener/CaptureScreenShotsListener.java Wed Aug 15 06:02:52 2012
@@ -61,7 +61,7 @@ public class CaptureScreenShotsListener
captureScreenshotAndSource( tr.getTestClass().getName(), tr.getThrowable() );
}
- private static void captureScreenshotAndSource( String cName, Throwable throwable )
+ public static void captureScreenshotAndSource( String cName, Throwable throwable )
{
Selenium selenium = AbstractSeleniumTest.getSelenium();
if ( selenium == null )
@@ -81,8 +81,20 @@ public class CaptureScreenShotsListener
String time = sdf.format( new Date() );
File targetPath = new File( "target", "screenshots" );
StackTraceElement trace = getStackTraceOfCallingClass( cName, throwable.getStackTrace() );
- String methodName = trace.getMethodName();
- int lNumber = trace.getLineNumber();
+ String methodName;
+ int lNumber;
+ if ( trace == null )
+ {
+ System.err.println( "Unable to determine the calling method from class " + cName );
+ throwable.printStackTrace();
+ methodName = "unknown";
+ lNumber = 0;
+ }
+ else
+ {
+ methodName = trace.getMethodName();
+ lNumber = trace.getLineNumber();
+ }
String lineNumber = Integer.toString( lNumber );
String className = cName.substring( cName.lastIndexOf( '.' ) + 1 );
if ( !targetPath.exists() && !targetPath.mkdirs() )