【问题标题】:TempDirectory extension: is there a replacement for createInCustomDirectory() methods?TempDirectory 扩展:是否可以替代 createInCustomDirectory() 方法?
【发布时间】:2019-02-11 07:01:42
【问题描述】:

在 JUnit 5.4.0-M1 的 TempDirectory 扩展类中曾经有 createInCustomDirectory() 方法(请参阅 docs)。这些方法的主要用例是更改扩展使用的 tmp 目录。在最终版本 (5.4.0) 中,TempDirectory 扩展被设为私有并默认启用,这些方法不再可用。

我想知道是否有另一种方法可以更改所有 @TempDir 目录的根目录?

【问题讨论】:

  • 对解决方法感兴趣的人的更新。在以下列方式运行测试时,您可以覆盖临时目录的系统属性:-Djava.io.tmpdir=/var/tmp。由于 JUnit 在内部使用 java.nio.file.Files#createTempDirectory,所以它可以解决问题。
  • 非常好的解决方法!

标签: junit5 junit5-extension-model


【解决方案1】:

不,没有办法自定义临时目录。

@TempDir 的范围在 JUnit 5.4 RC2 中缩小了。详情见以下问题:https://github.com/junit-team/junit5/issues/1752

【讨论】:

    猜你喜欢
    • 2010-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-11
    • 2011-07-27
    • 2016-09-29
    • 2016-09-22
    相关资源
    最近更新 更多