Testcontainers for .Net

I followed Getting started with Testcontainers for .NET at Getting started with Testcontainers for .NET

which works fine but I have a couple of questions:

1 - From where connectionstring to postgres comes from?

2 - Results are ouput to the screen, are they saved somewhere? if not saved, is it possible or is there a flag to save it to results file?

Thanks

It’s two years since I retired from the job where I used DotNet and PostGres, but iirc, GetConnectionString() gets the string from wherever you specify configuration values: Connection Strings - EF Core | Microsoft Learn

The container creates the connection string and results only show in test output unless you set up logging.

I know about connection strings but in the get started, CS is nowhere in the example. TA indicated just after your response that TestContainer creates by itself the connection string somewhere. He also said that I should setup logging to see it. So is it Docker log or dotnet log?

Thanks, I dfid add logging and was able to see the connection string. In fact I did the following (for anyone who needs to do the same thing)

1 - Add logging setup to CustomerServiceTest.cs, create ILoggerFactory, log container lifecycle events, route Testcontainers logs if possible.

private readonly ILoggerFactory _loggerFactory = LoggerFactory.Create(builder =>
{
builder
.AddConsole()
.SetMinimumLevel(LogLevel.Debug);
});

private readonly ILogger<CustomerServiceTest> _logger;

public CustomerServiceTest()
{
    // Logger factory is used to log test lifecycle events.
    _logger = _loggerFactory.CreateLogger<CustomerServiceTest>();
}

2 - Added a PackageReference for Microsoft.Extensions.Logging.Console

Then added logging in different places as follows, for example in InitializeAsync method

public async Task InitializeAsync()

    {

        _logger.LogDebug("Starting PostgreSQL testcontainer...");

        await _postgres.StartAsync();

        _logger.LogDebug("PostgreSQL testcontainer started. Connection string: {ConnectionString}", _postgres.GetConnectionString());

    }


@thenickward how about my 2nd question

2 - Results are ouput to the screen, are they saved somewhere? if not saved, is it possible or is there a flag to save it to results file??