问题标签 [junit5]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
2240 浏览

java - 如何通过 gradle systemProperties JUnit5 测试?

我正在使用gradle 3.5Unit 5 (jupiter)

我希望将系统属性传递给我的测试,以便配置测试

我正在使用此命令运行测试gradle test -Denv=envFile1

这是我的毕业文件:

这是我的测试:

这是我得到的输出:

*我已经更新了问题

0 投票
0 回答
85 浏览

java - Mockito 2.7.2.2 with JUnit5

I am currently trying that tutorial:

http://www.vogella.com/tutorials/Mockito/article.html

The Setup here starts with and that is not applicable

The Docu of JUnit says its deprecated and I couldn't find a docu how I can make mockito setting up with JUnit 5. Even that tutorial above is from April this year, the newest I found.

Question: I wonder if mockito is just incompatible to JUnit5? If not: How can I make it run? I found a similar question (How to use Mockito with JUnit5) and the answer from Nicolai is not working. He sugggest to use @Mock...yes, my IDE accepts it, BUT the Mocks are not working in tests like in the example below

Here is my test file (with no tests so far)

Instead of receiving "buffer size is negative" I get "no file attached". So the @Mock doesn't work?!?

and my POM

I know it would be faster to just use Junit4 instead of asking that question, but somehow it attracts me to solve problems :)

Edit:

I don't know why RPC marked that here as an exact duplicate of the link I shared above...Moreover the answer in that question is wrong, as I also stated here.

0 投票
0 回答
1540 浏览

jenkins - Junit5 html报告生成

最近从 JUnit4 迁移到 JUnit5。根据当前的 gradle 设置,我不再看到生成 HTML 报告。谷歌搜索但可以找到生成这些报告的方法。有没有人尝试在 JUnit5 下生成测试的 HTML 报告?

当我在 JUnit5 下运行测试时,我看到一个包含文件的二进制文件夹

因此html不会生成结果报告。

gradle.build帮助俱乐部test所有子项目中任务结果的代码

如果需要更多代码分享,请告诉我。

0 投票
2 回答
2722 浏览

java - 未运行 Spring Boot 应用程序的测试

我正在尝试为 Spring Boot 应用程序编写集成:

测试看起来像这样

但是,当我运行时gradlew test- 没有任何反应 - 构建成功并且报告为空。问题是什么?

build.gradle的是

0 投票
1 回答
224 浏览

android - 如何在 Junit 中检查字母数字条件

我试图为登录页面编写 Junit 测试用例。所以我想测试字母数字测试用例。如何在 Junit 中测试字母数字用例。我已经参考了这个链接Junit

0 投票
5 回答
8224 浏览

java - JUnit 5 中 ExternalResource 和 TemporaryFolder 的等价物是什么?

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

如上所述,JUnit Jupiter 本身不会也不会支持 JUnit 4 规则。然而,JUnit 团队意识到,许多组织,尤其是大型组织,可能拥有包括自定义规则在内的大型 JUnit 4 代码库。为了服务这些组织并实现逐步迁移路径,JUnit 团队决定在 JUnit Jupiter 中逐字支持选择 JUnit 4 规则。

该指南继续说,其中一个规则是ExternalResource,它是TemporaryFolder的父级。

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

0 投票
1 回答
1544 浏览

java - 动态测试与 JUnit 5 中的参数化测试有何不同?

我见过的几乎所有动态测试的例子,都可以使用参数化测试重新编写和编写。因此,这是一个实际场景,其中动态测试是唯一的选择,或者至少比参数化测试更适合。

JUnit 5 文档中唯一“真正”的动态测试示例并不实用。

有任何想法吗?

0 投票
2 回答
590 浏览

unit-testing - 如何使用 JUnit5 在 OpenEJB 中测试 EJB Bean?

在 JUnit 4 中,我使用以下设置来测试我的 EJB bean:

但在 JUnit 5 中,@RunWith(...)不再存在。

问题:如何使用 JUnit 5 进行测试?

0 投票
2 回答
2026 浏览

junit - 如何使用 Ant 执行 JUnit 5 @Tag 测试?

如何使用 Ant 运行带有注释的 JUnit 5 测试@Tag

例如:

在 Maven 中,我可以执行以下操作来包含或排除。但是我不知道如何让它在 Ant 中工作。

好心提醒。

0 投票
3 回答
4307 浏览

java - 事务回滚在 JUnit5 的 @Nested 类的测试用例中不起作用

我用的是spring-boot、JUnit5、Mybatis。

(1) 正在工作回滚。并输出以下日志。

但是,(2)不起作用。我希望能够回滚到@Nested.