com.shaft.tools.io.internal.FailureReporter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of SHAFT_ENGINE Show documentation
Show all versions of SHAFT_ENGINE Show documentation
SHAFT is a unified test automation engine. Powered by best-in-class frameworks, SHAFT provides a
wizard-like syntax to drive your automation efficiently, maximize your ROI, and minimize your learning curve.
Stop reinventing the wheel. Upgrade now!
package com.shaft.tools.io.internal;
import com.google.common.base.Throwables;
import com.shaft.gui.element.internal.ElementActionsHelper;
import com.shaft.tools.internal.support.JavaHelper;
import com.shaft.tools.io.ReportManager;
import org.testng.Assert;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class FailureReporter {
public static void fail(Class> failedFileManager, String message, Throwable throwable) {
String actionName = "fail";
String rootCause = " Root cause: \"" + Throwables.getRootCause(throwable).getClass().getName() + ": " + Throwables.getRootCause(throwable).getLocalizedMessage().split("\n")[0] + "\"";
for (StackTraceElement stackTraceElement : Arrays.stream(Thread.currentThread().getStackTrace()).toList()) {
var methodName = stackTraceElement.getMethodName();
if (!methodName.toLowerCase().contains("fail")) {
actionName = methodName;
break;
}
}
actionName = JavaHelper.convertToSentenceCase(actionName);
List> attachments = new ArrayList<>();
List