falcon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pisayc...@apache.org
Subject falcon git commit: FALCON-1283 Save screenshots to log.capture.location. Contributed by Ruslan Ostafiychuk
Date Mon, 22 Jun 2015 11:08:16 GMT
Repository: falcon
Updated Branches:
  refs/heads/master b73e34bd9 -> dc950f718


FALCON-1283 Save screenshots to log.capture.location. Contributed by Ruslan Ostafiychuk


Project: http://git-wip-us.apache.org/repos/asf/falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/falcon/commit/dc950f71
Tree: http://git-wip-us.apache.org/repos/asf/falcon/tree/dc950f71
Diff: http://git-wip-us.apache.org/repos/asf/falcon/diff/dc950f71

Branch: refs/heads/master
Commit: dc950f718992f5d54f6ec81da538992dfca8d246
Parents: b73e34b
Author: Paul Isaychuk <pisaychuk@apache.org>
Authored: Mon Jun 22 14:07:01 2015 +0300
Committer: Paul Isaychuk <pisaychuk@apache.org>
Committed: Mon Jun 22 14:07:01 2015 +0300

----------------------------------------------------------------------
 falcon-regression/CHANGES.txt                   |  2 ++
 .../falcon/regression/TestngListener.java       | 34 ++++++++++----------
 2 files changed, 19 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/falcon/blob/dc950f71/falcon-regression/CHANGES.txt
----------------------------------------------------------------------
diff --git a/falcon-regression/CHANGES.txt b/falcon-regression/CHANGES.txt
index 7499552..7c19724 100644
--- a/falcon-regression/CHANGES.txt
+++ b/falcon-regression/CHANGES.txt
@@ -93,6 +93,8 @@ Trunk (Unreleased)
    via Samarth Gupta)
 
   IMPROVEMENTS
+   FALCON-1283 Save screenshots to log.capture.location (Ruslan Ostafiychuk via Paul Isaychuk)
+
    FALCON-1259 Fix property picked for DIFFERENT_USER_GROUP (Raghav Kumar Gautam)
 
    FALCON-1261 ProcessSetupTest, EntitiesPatternSearchTest stabilization (Paul Isaychuk via
Raghav Kumar Gautam)

http://git-wip-us.apache.org/repos/asf/falcon/blob/dc950f71/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/TestngListener.java
----------------------------------------------------------------------
diff --git a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/TestngListener.java
b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/TestngListener.java
index ea472e6..277dff5 100644
--- a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/TestngListener.java
+++ b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/TestngListener.java
@@ -64,6 +64,13 @@ public class TestngListener implements ITestListener, IExecutionListener
{
     }
 
     private void endOfTestHook(ITestResult result, RunResult outcome) {
+        if (outcome != RunResult.SUCCESS) {
+            try {
+                takeScreenShot(result);
+            } catch (Exception e) {
+                LOGGER.info("Saving screenshot FAILED: " + e.getCause());
+            }
+        }
         try {
             dumpFalconStore(result);
         } catch (Exception e) {
@@ -105,30 +112,23 @@ public class TestngListener implements ITestListener, IExecutionListener
{
     @Override
     public void onTestFailure(ITestResult result) {
         endOfTestHook(result, RunResult.FAILED);
-        takeScreenShot(result);
 
         LOGGER.info(ExceptionUtils.getStackTrace(result.getThrowable()));
         LOGGER.info(hr);
     }
 
-    private void takeScreenShot(ITestResult result) {
+    private void takeScreenShot(ITestResult result) throws IOException {
+        String logs = Config.getProperty("log.capture.location", OSUtil.getPath("target",
"surefire-reports"));
         if (BaseUITestClass.getDriver() != null) {
-            byte[] scrFile =
-                ((TakesScreenshot)BaseUITestClass.getDriver()).getScreenshotAs(OutputType.BYTES);
-            try {
-                String params = Arrays.toString(result.getParameters());
-                params = params.replaceAll("[<>\":\\\\/\\|\\?\\*]", ""); //remove <>:"/\|?*
-                String filename = OSUtil.getPath("target", "surefire-reports", "screenshots",
-                    String.format("%s.%s(%s).png", result.getTestClass().getRealClass()
-                        .getSimpleName(), result.getName(), params));
-                FileUtils.writeByteArrayToFile(new File(filename), scrFile);
-            } catch (IOException e) {
-                LOGGER.info("Saving screenshot FAILED: " + e.getCause());
-            }
+            byte[] scrFile = ((TakesScreenshot)BaseUITestClass.getDriver()).getScreenshotAs(OutputType.BYTES);
+            String params = Arrays.toString(result.getParameters());
+            params = params.replaceAll("[<>\":\\\\/\\|\\?\\*]", ""); //remove <>:"/\|?*
+            String filename = OSUtil.getPath(logs, "screenshots",
+                String.format("%s.%s(%s).png", result .getTestClass().getRealClass().getSimpleName(),
+                    result.getName(), params));
+            LOGGER.info("Saving screenshot to: " + filename);
+            FileUtils.writeByteArrayToFile(new File(filename), scrFile);
         }
-
-        LOGGER.info(ExceptionUtils.getStackTrace(result.getThrowable()));
-        LOGGER.info(hr);
     }
 
     @Override


Mime
View raw message