From c31cf42a954d71e11d43c2f879e152f06702db4d Mon Sep 17 00:00:00 2001 From: SMan Date: Sun, 9 Jan 2022 15:49:30 -0600 Subject: [PATCH] fix: listener has been updated #1595; --- .../jans/as/server/JansUnitTestsListener.java | 43 ++++++++++++------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/server/src/test/java/io/jans/as/server/JansUnitTestsListener.java b/server/src/test/java/io/jans/as/server/JansUnitTestsListener.java index ef1eafef5f6..56651cd44ce 100644 --- a/server/src/test/java/io/jans/as/server/JansUnitTestsListener.java +++ b/server/src/test/java/io/jans/as/server/JansUnitTestsListener.java @@ -17,41 +17,40 @@ public class JansUnitTestsListener implements ITestListener { @Override - public void onFinish(ITestContext context) { + public void onTestStart(ITestResult result) { + Reporter.log("Test STARTED: " + getTestInfo(result), true); } @Override - public void onStart(ITestContext context) { + public void onTestSuccess(ITestResult result) { + Reporter.log("Test SUCCESS: " + getTestInfo(result), true); + Reporter.log("", true); } @Override - public void onTestFailedButWithinSuccessPercentage(ITestResult result) { - Reporter.log("Test FAILED with Success Percentage: " + result.getName() + "." + result.getMethod().getMethodName(), true); + public void onTestFailure(ITestResult result) { + Reporter.log("Test FAILED: " + getTestInfo(result), true); testFailed(result); } @Override - public void onTestFailure(ITestResult result) { - Reporter.log("Test FAILED: " + result.getName() + "." + result.getMethod().getMethodName(), true); - testFailed(result); - Reporter.log("", true); + public void onTestSkipped(ITestResult result) { + Reporter.log("Test SKIPPED: " + getTestInfo(result), true); + Reporter.log("", true); } @Override - public void onTestSkipped(ITestResult result) { - Reporter.log("Test SKIPPED: " + result.getName() + "." + result.getMethod().getMethodName(), true); - Reporter.log("", true); + public void onTestFailedButWithinSuccessPercentage(ITestResult result) { + Reporter.log("Test FAILED with Success Percentage: " + getTestInfo(result), true); + testFailed(result); } @Override - public void onTestStart(ITestResult result) { - Reporter.log("Test STARTED: " + result.getName() + "." + result.getMethod().getMethodName(), true); + public void onStart(ITestContext context) { } @Override - public void onTestSuccess(ITestResult result) { - Reporter.log("Test SUCCESS: " + result.getName() + "." + result.getMethod().getMethodName(), true); - Reporter.log("", true); + public void onFinish(ITestContext context) { } private void testFailed(ITestResult result) { @@ -70,4 +69,16 @@ private void testFailed(ITestResult result) { Reporter.log("", true); } } + + private String getTestInfo(ITestResult result) { + String testInfo = null; + if(result.getClass() != null && result.getMethod() != null) { + testInfo = result.getClass().getName() + "." + result.getMethod().getMethodName(); + } + else { + testInfo = result.getName(); + } + return testInfo; + } + }