diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2024-05-03 11:41:04 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2024-05-06 14:21:26 +0200 |
commit | 90a5df59eddccf630deec66f8d487dd1d69114a9 (patch) | |
tree | fc5498ee6a19c70ab27077e73b146342a634d065 /src/test/java/org/sonarsource/scanner/cli/StatsTest.java | |
parent | 9688ddf5c73288621cb431052196d0e7cae6080c (diff) | |
download | sonar-scanner-cli-90a5df59eddccf630deec66f8d487dd1d69114a9.tar.gz sonar-scanner-cli-90a5df59eddccf630deec66f8d487dd1d69114a9.zip |
SCANCLI-146 Log using slf4j + logback
Diffstat (limited to 'src/test/java/org/sonarsource/scanner/cli/StatsTest.java')
-rw-r--r-- | src/test/java/org/sonarsource/scanner/cli/StatsTest.java | 19 |
1 files changed, 9 insertions, 10 deletions
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 |