gradle-test-logger-plugin icon indicating copy to clipboard operation
gradle-test-logger-plugin copied to clipboard

Test output is shown twice for every test

Open christian-draeger opened this issue 2 years ago • 7 comments

Description

Every test is displayed twice in the gradle output but in different styles.

Versions

  • Test logger version: 3.1.0
  • Gradle version: 7.3.2
  • Java version: 16

Type of test being run

Junit5 tests

Test logger configuration

testlogger {
    theme = ThemeType.MOCHA_PARALLEL
    showSimpleNames = true
    slowThreshold = 1000
}

Screenshots

image

christian-draeger avatar Jan 03 '22 14:01 christian-draeger

I think one set of outputs is from Gradle. Do you have Gradle's testLogging configured as well?

radarsh avatar Jan 11 '22 16:01 radarsh

No, not knowingly. Here is the build file of one of the projects where I am using your test logger: https://github.com/skrapeit/skrape.it/blob/master/build.gradle.kts

It started logging all tests twice after I bumped the dependencies including this testlogger as well as the gradle version

christian-draeger avatar Jan 12 '22 20:01 christian-draeger

Can you try setting this in your build script and let me know if that fixes things?

test {
    testLogging {
+       showStandardStreams = false
    }
}

Up until 3.0.0, I used to reset any logging events set on the testLogging closure but doing so seems to be discouraged in Gradle 7. So I've removed the resetting logic. I am wondering if that has caused the issue you're seeing.

radarsh avatar Jan 16 '22 17:01 radarsh

Setting the showStandardStreams option to false unfortunately didn't change the result. Here is the commit deactivating the Standard streams with corresponding log output (hope you can see it) https://github.com/skrapeit/skrape.it/runs/4850664855?check_suite_focus=true

christian-draeger avatar Jan 18 '22 08:01 christian-draeger

Thanks, that was useful. Can I ask you to try setting this as well please?

test {
    testLogging {
+       lifecycle.events = []
    }
}

If this setting manages to hide the undesirable output, I will have to think of another way to revert the functionality which was previously present.

radarsh avatar Jan 18 '22 12:01 radarsh

this will throw an exception (i am using gradle kotlin dsl) image

christian-draeger avatar Jan 18 '22 18:01 christian-draeger

i turns out that configuring testLogging events as part of the test task e.g.

test {
    testLogging {
        events(TestLogEvent.PASSED, TestLogEvent. SKIPPED, TestLogEvent.FAILED)
    }
}

will lead to the described behavior. everything is working as expected when the events are removed. Not sure if thats intended or a bug.

christian-draeger avatar Jan 27 '22 14:01 christian-draeger