use of org.vividus.softassert.model.SoftAssertionError in project vividus by vividus-framework.
the class AllureStoryReporterTests method mockSoftAssertionError.
private AssertionFailedEvent mockSoftAssertionError(KnownIssue knownIssue) {
SoftAssertionError softAssertionError = new SoftAssertionError(null);
softAssertionError.setKnownIssue(knownIssue);
AssertionFailedEvent assertionFailedEvent = mock(AssertionFailedEvent.class);
when(assertionFailedEvent.getSoftAssertionError()).thenReturn(softAssertionError);
return assertionFailedEvent;
}
use of org.vividus.softassert.model.SoftAssertionError in project vividus by vividus-framework.
the class AbstractCloudTestStatusManagerTests method shouldUpdateCloudTestStatusToFailure.
@SuppressWarnings("unchecked")
@Test
void shouldUpdateCloudTestStatusToFailure() throws UpdateCloudTestStatusException {
SoftAssertionError assertionError = mock(SoftAssertionError.class);
when(webDriverProvider.isWebDriverInitialized()).thenReturn(true);
when(assertionError.isKnownIssue()).thenReturn(false);
statusManager.setCloudTestStatusToFailure(new AssertionFailedEvent(assertionError));
statusManager.setCloudTestStatusToFailure(new AssertionFailedEvent(assertionError));
statusManager.setCloudTestStatusToFailure(new AssertionFailedEvent(assertionError));
statusManager.updateCloudTestStatus(new BeforeWebDriverQuitEvent());
verify(statusManager).updateCloudTestStatus(FAILED);
verify(testContext, times(5)).get(any(Class.class), any(Supplier.class));
verify(testContext).remove(any(Class.class));
assertThat(logger.getLoggingEvents(), is(empty()));
}
use of org.vividus.softassert.model.SoftAssertionError in project vividus by vividus-framework.
the class SoftAssert method verify.
@Override
public void verify() throws VerificationError {
AssertionCollection assertionCollection = getAssertionCollection();
try {
List<SoftAssertionError> assertionErrors = assertionCollection.getAssertionErrors();
if (assertionErrors.isEmpty()) {
LOGGER.atInfo().log(() -> formatter.getPassedVerificationMessage(assertionCollection.getAssertionsCount()));
} else {
String errorsMessage = formatter.getErrorsMessage(assertionErrors, true);
LOGGER.atError().addArgument(formatter.getFailedVerificationMessage(assertionErrors, assertionCollection.getAssertionsCount())).addArgument(errorsMessage).log("{}{}");
throw new VerificationError(errorsMessage, assertionErrors);
}
} finally {
assertionCollection.clear();
}
}
use of org.vividus.softassert.model.SoftAssertionError in project vividus by vividus-framework.
the class SoftAssert method recordAssertionError.
protected void recordAssertionError(KnownIssue issue, String message, Throwable cause) {
SoftAssertionError assertionError = new SoftAssertionError(new AssertionError(message, cause));
assertionError.setKnownIssue(issue);
getAssertionCollection().addFailed(assertionError);
eventBus.post(new AssertionFailedEvent(assertionError));
if (assertionError.isFailTestSuiteFast()) {
failTestFastHandler.failTestSuiteFast();
}
if (failTestCaseFast && !assertionError.isKnownIssue() || assertionError.isFailTestCaseFast()) {
failTestFastHandler.failTestCaseFast();
}
}
use of org.vividus.softassert.model.SoftAssertionError in project vividus by vividus-framework.
the class AssertionFormatter method getErrorsMessage.
@Override
public String getErrorsMessage(List<SoftAssertionError> errors, boolean includeStackTraceInformation) {
Writer writer = new StringWriter();
try (PrintWriter printWriter = new PrintWriter(writer)) {
int index = 1;
for (SoftAssertionError error : errors) {
if (index == 1 || !includeStackTraceInformation) {
printWriter.println();
}
printWriter.print(index++);
printWriter.print(") ");
AssertionError assertionError = error.getError();
if (includeStackTraceInformation) {
if (stackTraceFilter != null) {
stackTraceFilter.printFilteredStackTrace(assertionError, printWriter);
} else {
assertionError.printStackTrace(printWriter);
}
} else {
printWriter.print(assertionError.getMessage());
}
}
}
return writer.toString();
}
Aggregations