testcontainers / testcontainers/testcontainers-java
[Feature]: JUnit Jupiter extension for reuse of containers
Nessuno ha ancora preso questa issue.
- Lingua principale
- Java
- Stelle
- 8.7k
- Fork
- 1.9k
- Merge medio
- 2g 17h
- PR unite (30g)
- 9
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia nel modulo Core e leggi i callback del ciclo di vita dell’API delle estensioni JUnit Jupiter a cui si fa riferimento nell’issue. Definisci come le annotazioni proposte ContainerConfig e ContainerProvider debbano registrare e riutilizzare i container tra le classi di test, quindi verifica che le istanze condivise vengano create una sola volta mentre le richieste needNewInstance rimangano isolate.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- docker, java
- Ambito
- testing
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100