From 9167edb979efa5e85601a381d428bfd1952ace3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gro=C3=9Fmann?= Date: Fri, 26 Nov 2021 17:23:27 +0100 Subject: [PATCH] Fixed new synchronizer --- .../azuredevops/hook/AzureDevOpsConnectorHook.java | 4 ++-- .../synchronize/AzureDevOpsResultSynchronizer.java | 12 ++++++++++-- .../plugins/azuredevops/tests/PlaygroundTests.java | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/eu/tsystems/mms/tic/testerra/plugins/azuredevops/hook/AzureDevOpsConnectorHook.java b/src/main/java/eu/tsystems/mms/tic/testerra/plugins/azuredevops/hook/AzureDevOpsConnectorHook.java index e89340e..d7a8ed0 100644 --- a/src/main/java/eu/tsystems/mms/tic/testerra/plugins/azuredevops/hook/AzureDevOpsConnectorHook.java +++ b/src/main/java/eu/tsystems/mms/tic/testerra/plugins/azuredevops/hook/AzureDevOpsConnectorHook.java @@ -24,7 +24,6 @@ import eu.tsystems.mms.tic.testerra.plugins.azuredevops.synchronize.AzureDevOpsResultSynchronizer; import eu.tsystems.mms.tic.testframework.hooks.ModuleHook; -import eu.tsystems.mms.tic.testframework.logging.Loggable; import eu.tsystems.mms.tic.testframework.report.TesterraListener; /** @@ -32,7 +31,7 @@ * * @author mgn */ -public class AzureDevOpsConnectorHook implements ModuleHook, Loggable { +public class AzureDevOpsConnectorHook implements ModuleHook { private static AzureDevOpsResultSynchronizer synchronizer; @@ -40,6 +39,7 @@ public class AzureDevOpsConnectorHook implements ModuleHook, Loggable { public void init() { synchronizer = new AzureDevOpsResultSynchronizer(); TesterraListener.getEventBus().register(synchronizer); + } @Override diff --git a/src/main/java/eu/tsystems/mms/tic/testerra/plugins/azuredevops/synchronize/AzureDevOpsResultSynchronizer.java b/src/main/java/eu/tsystems/mms/tic/testerra/plugins/azuredevops/synchronize/AzureDevOpsResultSynchronizer.java index 76ad10e..09155b8 100644 --- a/src/main/java/eu/tsystems/mms/tic/testerra/plugins/azuredevops/synchronize/AzureDevOpsResultSynchronizer.java +++ b/src/main/java/eu/tsystems/mms/tic/testerra/plugins/azuredevops/synchronize/AzureDevOpsResultSynchronizer.java @@ -22,6 +22,7 @@ package eu.tsystems.mms.tic.testerra.plugins.azuredevops.synchronize; +import com.google.common.eventbus.Subscribe; import eu.tsystems.mms.tic.testerra.plugins.azuredevops.annotation.AzureTest; import eu.tsystems.mms.tic.testerra.plugins.azuredevops.config.AzureDevOpsConfig; import eu.tsystems.mms.tic.testerra.plugins.azuredevops.mapper.FailureType; @@ -33,11 +34,13 @@ import eu.tsystems.mms.tic.testerra.plugins.azuredevops.mapper.RunState; import eu.tsystems.mms.tic.testerra.plugins.azuredevops.mapper.Testplan; import eu.tsystems.mms.tic.testerra.plugins.azuredevops.restclient.AzureDevOpsClient; +import eu.tsystems.mms.tic.testframework.annotations.Fails; import eu.tsystems.mms.tic.testframework.events.TestStatusUpdateEvent; import eu.tsystems.mms.tic.testframework.logging.Loggable; import eu.tsystems.mms.tic.testframework.report.Status; import eu.tsystems.mms.tic.testframework.report.model.context.ErrorContext; import eu.tsystems.mms.tic.testframework.report.model.context.MethodContext; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; import java.lang.reflect.Method; @@ -64,6 +67,7 @@ public AzureDevOpsResultSynchronizer() { } @Override + @Subscribe public void onTestStatusUpdate(TestStatusUpdateEvent event) { MethodContext methodContext = event.getMethodContext(); @@ -185,9 +189,14 @@ private synchronized void syncTestresult(TestStatusUpdateEvent event, Outcome ou .findFirst() .ifPresent(errorContext -> { Throwable throwable = errorContext.getThrowable(); - final String errorMessage = throwable.getMessage(); + String errorMessage = throwable.getMessage(); + Optional fails = event.getMethodContext().getFailsAnnotation(); + if (fails.isPresent() && StringUtils.isNotBlank(fails.get().description())) { + errorMessage += "\n\nKnown issue: " + fails.get().description(); + } result.setErrorMessage(errorMessage); result.setFailureType(this.getFailureType(event).toString()); + event.getMethodContext().getFailsAnnotation().get().description(); final String stackTrace = ExceptionUtils.getStackTrace(throwable); result.setStackTrace(stackTrace); }); @@ -222,7 +231,6 @@ private synchronized void syncTestresult(TestStatusUpdateEvent event, Outcome ou } // end method.isPresent - } public void shutdown() { diff --git a/src/test/java/eu/tsystems/mms/tic/testerra/plugins/azuredevops/tests/PlaygroundTests.java b/src/test/java/eu/tsystems/mms/tic/testerra/plugins/azuredevops/tests/PlaygroundTests.java index 751549c..cf92180 100644 --- a/src/test/java/eu/tsystems/mms/tic/testerra/plugins/azuredevops/tests/PlaygroundTests.java +++ b/src/test/java/eu/tsystems/mms/tic/testerra/plugins/azuredevops/tests/PlaygroundTests.java @@ -57,7 +57,7 @@ public void test_Passed01() { @Test @AzureTest(id = 2284) -// @Fails(description = "Das ist halt ein alter Bug.") + @Fails(description = "Das ist halt ein alter Bug.") public void test_Passed02() { TimerUtils.sleep(5555, "Wait some time..."); Assert.assertTrue(false, "Mega exception");