Setting system properties when using junitPlatform

前端 未结 1 832
鱼传尺愫
鱼传尺愫 2021-01-18 11:55

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:



        
1条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-18 12:08

    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'
    }
    

    0 讨论(0)
提交回复
热议问题