continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1373222 - /continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/listener/CaptureScreenShotsListener.java
Date Wed, 15 Aug 2012 06:02:52 GMT
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() )



Mime
View raw message