Setting system properties when using junitPlatform
Asked Answered
H

1

6

I could not find out how to set system properties when executing JUnit 5 tests using Gradle. The standard test task could be configured as follows:

test {
     systemProperty 'org.slf4j.simpleLogger.defaultLogLevel', 'warn'
}

However, the junitPlatform task seem to not have such an option.

Hoeg answered 26/12, 2016 at 12:20 Comment(0)
B
12

Update:

Please note that the junit-platform-gradle-plugin developed by the JUnit Team was deprecated in JUnit Platform 1.2 and discontinued in 1.3. Please switch to Gradle’s standard test task in Gradle 4.6 or higher. Details here.


As I mentioned here, if you are still using the obsolete junit-platform-gradle-plugin you can set system properties like this:

afterEvaluate {
    def junitPlatformTestTask = tasks.getByName('junitPlatformTest')

    junitPlatformTestTask.systemProperty 'org.slf4j.simpleLogger.defaultLogLevel', 'warn'
}
Blindage answered 26/12, 2016 at 18:3 Comment(2)
You're welcome! I also just linked to JGiven from here: github.com/junit-team/junit5/issues/297Blindage
Thank you so much. I don't know how much time I wasted in Junit 5 related issues.Upper

© 2022 - 2024 — McMap. All rights reserved.