Search in sources :

Example 16 with LoggingEvent

use of com.github.valfirst.slf4jtest.LoggingEvent in project vividus by vividus-framework.

the class VariableTestContextTests method shouldPutVariablesIntoAllPassedScopes.

@Test
void shouldPutVariablesIntoAllPassedScopes() {
    Set<VariableScope> variableScopes = Set.of(VariableScope.STEP, VariableScope.SCENARIO, VariableScope.STORY, VariableScope.NEXT_BATCHES);
    Variables variables = new Variables(Map.of());
    variables.initStepVariables();
    when(variablesFactory.createVariables()).thenReturn(variables);
    variableTestContext.putVariable(variableScopes, VARIABLE_KEY, VALUE);
    assertEquals(VALUE, variables.getVariable(VARIABLE_KEY));
    variables.clearStepVariables();
    assertEquals(VALUE, variables.getVariable(VARIABLE_KEY));
    variables.clearScenarioVariables();
    assertEquals(VALUE, variables.getVariable(VARIABLE_KEY));
    List<LoggingEvent> loggingEvents = logger.getLoggingEvents();
    assertThat(loggingEvents, hasSize(4));
    assertThat(loggingEvents, hasItems(info(SAVE_MESSAGE_TEMPLATE, VALUE, STEP, VARIABLE_KEY), info(SAVE_MESSAGE_TEMPLATE, VALUE, "scenario", VARIABLE_KEY), info(SAVE_MESSAGE_TEMPLATE, VALUE, "story", VARIABLE_KEY), info(SAVE_MESSAGE_TEMPLATE, VALUE, "next batches", VARIABLE_KEY)));
    verify(variablesFactory).addNextBatchesVariable(VARIABLE_KEY, VALUE);
}
Also used : Variables(org.vividus.variable.Variables) LoggingEvent(com.github.valfirst.slf4jtest.LoggingEvent) VariableScope(org.vividus.variable.VariableScope) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 17 with LoggingEvent

use of com.github.valfirst.slf4jtest.LoggingEvent in project vividus by vividus-framework.

the class FilesystemScreenshotDebuggerTests method shouldSaveScreenshotIntoDebugFolder.

@Test
void shouldSaveScreenshotIntoDebugFolder(@TempDir File debugFolder) {
    filesystemScreenshotDebugger.setDebugScreenshotsLocation(Optional.of(debugFolder));
    filesystemScreenshotDebugger.debug(FilesystemScreenshotDebuggerTests.class, SUFFIX, new BufferedImage(10, 10, 5));
    List<LoggingEvent> loggingEvents = testLogger.getLoggingEvents();
    assertThat(loggingEvents, Matchers.hasSize(1));
    LoggingEvent loggingEvent = loggingEvents.get(0);
    String message = loggingEvent.getMessage();
    assertEquals("Debug screenshot saved to {}", message);
    assertEquals(Level.DEBUG, loggingEvent.getLevel());
    assertThat(loggingEvent.getArguments().get(0).toString(), stringContainsInOrder(List.of(debugFolder.toString(), "FilesystemScreenshotDebuggerTests_suffix.png")));
    assertEquals(1, debugFolder.listFiles().length);
}
Also used : LoggingEvent(com.github.valfirst.slf4jtest.LoggingEvent) BufferedImage(java.awt.image.BufferedImage) Test(org.junit.jupiter.api.Test)

Example 18 with LoggingEvent

use of com.github.valfirst.slf4jtest.LoggingEvent in project vividus by vividus-framework.

the class SshOutputPublisherTests method publishOutputWithoutError.

@Test
void publishOutputWithoutError() {
    String output = "success";
    SshOutput sshOutput = new SshOutput();
    sshOutput.setOutputStream(output);
    sshOutputPublisher.publishOutput(sshOutput);
    LoggingEvent loggingEvent = verifyStdoutAttachmentPublishing(output);
    verifyNoMoreInteractions(attachmentPublisher);
    assertThat(logger.getLoggingEvents(), equalTo(List.of(loggingEvent)));
}
Also used : LoggingEvent(com.github.valfirst.slf4jtest.LoggingEvent) Test(org.junit.jupiter.api.Test)

Aggregations

LoggingEvent (com.github.valfirst.slf4jtest.LoggingEvent)18 Test (org.junit.jupiter.api.Test)17 Scope (io.opentracing.Scope)2 Span (io.opentracing.Span)2 MockSpan (io.opentracing.mock.MockSpan)2 BufferedImage (java.awt.image.BufferedImage)2 Path (java.nio.file.Path)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 TestCase (org.vividus.zephyr.model.TestCase)2 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URI (java.net.URI)1 Files (java.nio.file.Files)1 Connection (java.sql.Connection)1 Statement (java.sql.Statement)1 ArrayList (java.util.ArrayList)1 DataSource (javax.sql.DataSource)1 Component (net.kyori.adventure.text.Component)1