2016-12-26 89 views
3

我无法知道如何使用Gradle执行JUnit 5测试时设置系统属性。标准test任务可以被配置如下:使用junitPlatform时设置系统属性

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

然而,junitPlatform任务似乎没有这样的选择。

回答

8

正如我所提到here,您可以设置系统属性是这样的:

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

    junitPlatformTestTask.systemProperty 'org.slf4j.simpleLogger.defaultLogLevel', 'warn' 
} 
+0

是的,这确实起作用。谢谢! –

+0

不客气!我也从这里链接到JGiven:https://github.com/junit-team/junit5/issues/297 –

+0

酷。谢谢! –