中的ExternalResource和TemporaryFold

中的ExternalResource和TemporaryFold

本文介绍了JUnit 5中的ExternalResource和TemporaryFolder的等价物是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据,JUnit Jupiter为某些JUnit 4规则提供向后兼容性以帮助迁移。

According to the JUnit 5 User Guide, JUnit Jupiter provides backwards compatibility for some JUnit 4 Rules in order to assist with migration.

该指南继续说其中一条规则是,它是。

The guide goes on to say that one of the rules is ExternalResource, which is a parent for TemporaryFolder.

然而,该指南遗憾的是没有继续说什么迁移路径是,或者对于那些编写新的JUnit 5测试的人来说是等价的。那么我们应该使用什么?

However, the guide unfortunately doesn't go on to say what the migration path is, or what the equivalent is for those writing new JUnit 5 tests. So what should we use?

推荐答案

JUnit5.0.0现已全面发布,所以我们希望他们把注意力转移到让生产准备就绪的实验性产品上。

JUnit5.0.0 is now in general release so let's hope they turn their attention to making the experimental stuff production-ready.

同时,似乎TemporaryFolder规则仍然适用于JUnit5

Meanwhile, it seems the TemporaryFolder rule will still work with JUnit5 docs

使用此:

@EnableRuleMigrationSupport
public class MyJUnit5Test {

和此:

<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter-migrationsupport</artifactId>
    <version>5.0.0</version>
</dependency>

这篇关于JUnit 5中的ExternalResource和TemporaryFolder的等价物是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 13:11