Skip to content

Add dedicated section for registering a container as a bean in the Testcontainers section #43738

Closed as not planned
@michaldo

Description

@michaldo

Two issues are unclear in documentation

  1. Probably outdated examples with @Testcontainers
    Every example contains @Testcontainers annotation. It seems be unnecessary. For example, Spring Initializer generates working test classes without the annotation. (If I'm right, I can create PR with @Testcontainers removal)

  2. Two methods to register Container without explanation
    Container can be registered with @org.testcontainers.junit.jupiter.Container annotation or as a Spring @Bean. Which one is better for which case? On one hand, Spring Initializer generates @Bean, so it looks as recommended. On the other hand, Spring Boot Reference begins with @Container, to it looks as primary decision hint. @Container is a bit boilerplate-less, so the hint looks reasonable.
    As a developer, which method should I choose at the beginning?
    (ref: https://docs.spring.io/spring-boot/reference/testing/testcontainers.html)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions