java - Java:如何在 Spring Boot 测试中实现 @BeforeAll 和 @AfterAll?
问题描述
有没有其他方法可以在 junit5 中为 Spring Boot 应用程序使用 @BeforeAll 和 @AfterAll 逻辑?它看起来像 Spring Boot 只是忽略了这些注释。测试类以注释开头:
@ExtendWith(SpringExtension.class)
@SpringBootTest
我还尝试覆盖类 AbstractTestExecutionListener 的 beforeTestClass 和 afterTestClass 方法并添加注释:
@TestExecutionListeners(listeners =
{DependencyInjectionTestExecutionListener.class, SearchManagerTest.class})
但 Spring Boot 也忽略了它。
解决方案
推荐阅读
- android - 无法删除 Android tabLayout 中的操作栏
- python - 有没有办法根据特定数组而不是索引绘制 Matplotlib 的 Imshow?
- ruby-on-rails - Rails GraphQL 嵌套突变/查询结构
- javascript - 有没有办法一次从紫色空中服务器获取 3 个请求而不会被阻塞?
- qt - 如何使这个 OpenGL (Qt3D) 代码高效?
- javascript - 错误事件上的 fs.createWriteStream 不会捕获错误
- spring - 协程上下文有什么问题?
- mongodb - 将现有的 Strapi 应用程序从使用 Sqlite3 迁移到使用 MongoDB
- python - 为什么升级到 v2.2 后 Django 会发送重复的错误消息?
- sql - 如何在 SQL 中转置查询结果?