testcontainers / testcontainers/testcontainers-java

[Feature]: JUnit Jupiter extension for reuse of containers

未关闭
#6,401 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

type/feature
主要语言
Java
星标
8.7k
派生
1.9k
平均合并
2 天 17 小时
30 天内合并 PR
9

描述

Module

Core

Problem

Assume you have several integration tests splitted in some classes. All this tests can reuse the same container instance. If the container needs some time to setup that would be a great benefit.

Solution

By using the JUnit extension API it would be easy to create a custom annotation like this:

@ContainerConfig(name="containerA", needNewInstance=false) public void testFoo() {}

A container that is needed could be simply defined by a provider:

@ContainerProvider(name="containerA") public GenericContainer<?> createContainerA() {}

By using test lifecycle callbacks (https://junit.org/junit5/docs/current/user-guide/#extensions-lifecycle-callbacks) this could be achieved as a JUnit extension.

I would be happy to help by creating the feature :)

Benefit

Containers that are needed for multiple tests in multiple classes only need to be defined once and the instances can be reused.

Alternatives
Would you like to help contributing this feature?

Yes

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 Core 模块开始,阅读 issue 中引用的 JUnit Jupiter 扩展 API 生命周期回调。定义所提议的 ContainerConfig 和 ContainerProvider 注解应如何在测试类之间注册和复用容器,然后验证共享实例只创建一次,而 needNewInstance 请求保持隔离。

由索引模型根据 Issue 内容生成。

评估

技术栈
docker, java
领域
testing
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。