From ec8d292e700e3f0e2572ad33edf4e0ea800326ec Mon Sep 17 00:00:00 2001 From: Joke de Buhr Date: Tue, 12 Mar 2024 18:10:22 +0100 Subject: [PATCH] test: clear output Signed-off-by: Joke de Buhr --- .../io/github/joke/test/ServiceTest.groovy | 1 - .../groovy/io/github/joke/test/TypedLogs.groovy | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/examples/slf4j/src/test/groovy/io/github/joke/test/ServiceTest.groovy b/examples/slf4j/src/test/groovy/io/github/joke/test/ServiceTest.groovy index 2090ca8..28940dc 100644 --- a/examples/slf4j/src/test/groovy/io/github/joke/test/ServiceTest.groovy +++ b/examples/slf4j/src/test/groovy/io/github/joke/test/ServiceTest.groovy @@ -47,5 +47,4 @@ class ServiceTest extends Specification { globalLogs ==~ /(?s).*Hello Universe.*/ localLogs ==~ /(?s).*Hello Universe.*/ } - } diff --git a/examples/slf4j/src/test/groovy/io/github/joke/test/TypedLogs.groovy b/examples/slf4j/src/test/groovy/io/github/joke/test/TypedLogs.groovy index d874e54..b9fecd0 100644 --- a/examples/slf4j/src/test/groovy/io/github/joke/test/TypedLogs.groovy +++ b/examples/slf4j/src/test/groovy/io/github/joke/test/TypedLogs.groovy @@ -64,4 +64,21 @@ class TypedLogs extends Specification { globalLogs.lines ==~ /(?s).*Hello Universe.*/ localLogs.lines==~ /(?s).*Hello Universe.*/ } + + def 'clear logger'() { + when: + localLogger.logSomething('Hello Test') + + then: + localLogs ==~ /(?s).*Hello Test.*/ + + and: + when: + localLogs.clear() + localLogger.logSomething('Hello again Test') + + then: + !(localLogs ==~ /(?s).*Hello Test.*/) + localLogs ==~ /(?s).*Hello again Test.*/ + } }