From 90a5df59eddccf630deec66f8d487dd1d69114a9 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Fri, 3 May 2024 11:41:04 +0200 Subject: SCANCLI-146 Log using slf4j + logback --- .../java/org/sonarsource/scanner/cli/StatsTest.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/test/java/org/sonarsource/scanner/cli/StatsTest.java') diff --git a/src/test/java/org/sonarsource/scanner/cli/StatsTest.java b/src/test/java/org/sonarsource/scanner/cli/StatsTest.java index a39e9ec..4895640 100644 --- a/src/test/java/org/sonarsource/scanner/cli/StatsTest.java +++ b/src/test/java/org/sonarsource/scanner/cli/StatsTest.java @@ -19,25 +19,24 @@ */ package org.sonarsource.scanner.cli; -import java.io.PrintStream; import org.junit.jupiter.api.Test; -import org.mockito.Mockito; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.slf4j.event.Level; +import testutils.LogTester; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; class StatsTest { - private final PrintStream stdOut = mock(PrintStream.class); - private final PrintStream stdErr = mock(PrintStream.class); - private final Logs logs = new Logs(stdOut, stdErr); + @RegisterExtension + LogTester logTester = new LogTester(); @Test void shouldPrintStats() { - new Stats(logs).start().stop(); + new Stats().start().stop(); - verify(stdOut).println(Mockito.contains("Total time: ")); - verify(stdOut).println(Mockito.contains("Final Memory: ")); + assertThat(logTester.logs(Level.INFO)).hasSize(2); + assertThat(logTester.logs(Level.INFO).get(0)).startsWith("Total time: "); + assertThat(logTester.logs(Level.INFO).get(1)).startsWith("Final Memory: "); } @Test -- cgit v1.2.3