Skip to content

Commit

Permalink
Fixed new synchronizer
Browse files Browse the repository at this point in the history
  • Loading branch information
martingrossmann committed Nov 26, 2021
1 parent 9491698 commit 9167edb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@

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;

/**
* Created on 17.11.2020
*
* @author mgn
*/
public class AzureDevOpsConnectorHook implements ModuleHook, Loggable {
public class AzureDevOpsConnectorHook implements ModuleHook {

private static AzureDevOpsResultSynchronizer synchronizer;

@Override
public void init() {
synchronizer = new AzureDevOpsResultSynchronizer();
TesterraListener.getEventBus().register(synchronizer);

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -64,6 +67,7 @@ public AzureDevOpsResultSynchronizer() {
}

@Override
@Subscribe
public void onTestStatusUpdate(TestStatusUpdateEvent event) {

MethodContext methodContext = event.getMethodContext();
Expand Down Expand Up @@ -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> 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);
});
Expand Down Expand Up @@ -222,7 +231,6 @@ private synchronized void syncTestresult(TestStatusUpdateEvent event, Outcome ou

} // end method.isPresent


}

public void shutdown() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 9167edb

Please sign in to comment.