use of com.github.valfirst.slf4jtest.LoggingEvent in project vividus by vividus-framework.
the class DescriptiveSoftAssertTests method testAssertThat.
@Test
void testAssertThat() {
LoggingEvent expectedEvent = new LoggingEvent(Level.DEBUG, "Pass: {}", SYSTEM_DESCRIPTION + StringUtils.SPACE + "\"test\"");
assertTrue(descriptiveSoftAssert.assertThat(BUSINESS_DESCRIPTION, SYSTEM_DESCRIPTION, TEST, equalTo(TEST)));
verify(assertionCollection).addPassed();
assertTrue(logger.getAllLoggingEvents().contains(expectedEvent));
}
use of com.github.valfirst.slf4jtest.LoggingEvent in project vividus by vividus-framework.
the class FilesystemScreenshotDebuggerTests method shouldLogIOException.
@Test
void shouldLogIOException() {
File path = new File("route_66");
filesystemScreenshotDebugger.setDebugScreenshotsLocation(Optional.of(path));
filesystemScreenshotDebugger.debug(FilesystemScreenshotDebuggerTests.class, "", new BufferedImage(10, 10, 5));
List<LoggingEvent> loggingEvents = testLogger.getLoggingEvents();
LoggingEvent loggingEvent = loggingEvents.get(0);
String message = loggingEvent.getMessage();
assertThat(loggingEvents, Matchers.hasSize(1));
assertEquals(Level.DEBUG, loggingEvent.getLevel());
assertEquals("Unable to save debug screenshot to {}", message);
assertThat(loggingEvent.getArguments().get(0).toString(), stringContainsInOrder(List.of(path.toString(), "FilesystemScreenshotDebuggerTests_.png")));
assertThat(loggingEvent.getThrowable().get(), is(instanceOf(IIOException.class)));
}
use of com.github.valfirst.slf4jtest.LoggingEvent in project vividus by vividus-framework.
the class SshOutputPublisherTests method publishOutputWithError.
@Test
void publishOutputWithError() {
String output = "fail";
String error = "error";
SshOutput sshOutput = new SshOutput();
sshOutput.setOutputStream(output);
sshOutput.setErrorStream(error);
sshOutputPublisher.publishOutput(sshOutput);
LoggingEvent outputLoggingEvent = verifyStdoutAttachmentPublishing(output);
LoggingEvent errorLoggingEvent = verifyStderrAttachmentPublishing(error);
verifyNoMoreInteractions(attachmentPublisher);
assertThat(logger.getLoggingEvents(), equalTo(List.of(outputLoggingEvent, errorLoggingEvent)));
}
use of com.github.valfirst.slf4jtest.LoggingEvent in project vividus by vividus-framework.
the class XrayExporterTests method shouldFailIfMoreThanOneIdIsSpecified.
@Test
void shouldFailIfMoreThanOneIdIsSpecified() throws URISyntaxException, IOException {
URI jsonResultsUri = getJsonResultsUri("morethanoneid");
xrayExporterOptions.setJsonResultsDirectory(Paths.get(jsonResultsUri));
xrayExporter.exportResults();
List<LoggingEvent> loggingEvents = new ArrayList<>(logger.getLoggingEvents());
LoggingEvent errorEvent = loggingEvents.remove(2);
assertEquals(ERROR_MESSAGE, errorEvent.getMessage());
Optional<Throwable> eventThorable = errorEvent.getThrowable();
assertTrue(eventThorable.isPresent());
Throwable throwable = eventThorable.get();
assertThat(throwable, instanceOf(NotUniqueMetaValueException.class));
String errorMessage = "Expected only one value for the 'testCaseId' meta, but got: STUB-0, STUB-1, STUB-2";
assertEquals(errorMessage, throwable.getMessage());
validateLogs(loggingEvents, jsonResultsUri, getExportingScenarioEvent(), getReportErrorEvent(errorMessage));
}
use of com.github.valfirst.slf4jtest.LoggingEvent in project vividus by vividus-framework.
the class TestCaseParserTests method testCreateTestCases.
@Test
void testCreateTestCases() throws URISyntaxException, IOException {
var objectMapper = configureObjectMapper();
Path sourceDirectory = Paths.get(getClass().getResource(RESOURCE_PATH).toURI());
when(zephyrExporterProperties.getSourceDirectory()).thenReturn(sourceDirectory);
when(zephyrExporterProperties.getStatusesOfTestCasesToAddToExecution()).thenReturn(List.of(TestCaseStatus.SKIPPED, TestCaseStatus.PASSED));
List<TestCase> testCases = testCaseParser.createTestCases(objectMapper);
assertEquals(testCases.size(), 2);
List<LoggingEvent> events = testLogger.getLoggingEvents();
assertThat(events.get(0).getMessage(), is(JSON_FILES_STRING));
assertThat(events.get(0).getLevel(), is(Level.INFO));
assertThat(events.get(1).getMessage(), is(TEST_CASES_STRING));
assertThat(events.get(1).getLevel(), is(Level.INFO));
assertThat(events.get(2).getMessage(), is(FOR_EXPORTING_STRING));
assertThat(events.get(2).getLevel(), is(Level.INFO));
assertThat(events.size(), equalTo(3));
}
Aggregations