【问题标题】:Junit5 TemporaryFolderExtension dependencyJunit5 TemporaryFolderExtension 依赖
【发布时间】:2018-11-09 22:00:01
【问题描述】:

我有依赖:

<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter-api</artifactId>
    <version>${junit.jupiter.version}</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter-params</artifactId>
    <version>${junit.jupiter.version}</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter-engine</artifactId>
    <version>${junit.jupiter.version}</version>
    <scope>test</scope>
</dependency>

(与&lt;junit.jupiter.version&gt;5.3.1&lt;/junit.jupiter.version&gt;

当我尝试使用 @ExtendWith(TemporaryFolderExtension.class) 时,Intellij 无法找到任何可以从中导入它的来源。 我试图谷歌,但我似乎无法找到什么神器会有它......

【问题讨论】:

    标签: java junit5 junit-jupiter


    【解决方案1】:

    直到版本 5.3.2 JUnit 5 本身提供TemporaryFolderExtension(请参阅https://github.com/junit-team/junit5/issues/1247),您必须求助于 JUnit 5 扩展包名为JUnit Pioneer

    但是,从版本 5.4.0-M1 开始,名为 TempDirectory 的临时文件夹扩展由 junit-jupiter-api 工件直接提供。

    【讨论】:

      【解决方案2】:

      你可以试试这个,不用提版本:

          <dependency>
              <groupId>org.junit.jupiter</groupId>
              <artifactId>junit-jupiter-api</artifactId>
              <scope>test</scope>
          </dependency>
      

      【讨论】:

      • 谢谢,我们项目的结构方式,我们有一个指定版本的主 POM 文件,然后子模块(在这种情况下,应用程序模块)具有已经列出的依赖项而没有提及版本,所以它可以引用主 POM 文件中的那个。我想这和你的意思一样吧?
      • @Carmageddon 是的。如果您在 IDEA 中,请尝试通过单击选项卡手动重新导入所有 Maven 项目 Maven 项目 -> 重新导入
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-11-27
      • 1970-01-01
      • 2020-03-10
      • 1970-01-01
      • 2018-04-08
      • 2019-04-18
      • 1970-01-01
      相关资源
      最近更新 更多