Connection String Provider
The Connection String Provider API provides a standardized way to access and manage connection information for Testcontainers (modules). It allows developers to customize module-provided connection strings or add their own, and to access module-specific connection strings or endpoints (e.g., database connection strings, HTTP API base addresses) in a uniform way.
Note
Testcontainers modules do not yet implement this feature. Developers can use the provider to define and manage their own connection strings or endpoints. Providers will be integrated by modules in future releases.
Example
Register a custom connection string provider via the container builder:
1 2 3 4 5 6 7 8 9 10 11 12 | |
Implementing a custom provider
To create a custom provider, implement the generic interface: IConnectionStringProvider<TContainer, TConfiguration>. The Configure(TContainer, TConfiguration) method is invoked after the container has successfully started, ensuring that all runtime-assigned values are available.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |