Recently, at work, my team took a look into the very promising Testcontainers for .NET library.
The Demo Project in GitHub shows the simple tests that work perfectly well in any IDE and on the CLI.
But when running in Azure Devops, we get this error:
System.AggregateException : One or more errors occurred. (Cannot detect the Docker endpoint. Use either the environment variables or the ~/.testcontainers.properties file to customize your configuration:
https://dotnet.testcontainers.org/custom_configuration/ (Parameter 'DockerEndpointAuthConfig')) (The following constructor parameters did not have matching fixture data: SqlServerWebApplicationFactory factory)
---- System.ArgumentException : Cannot detect the Docker endpoint. Use either the environment variables or the ~/.testcontainers.properties file to customize your configuration:
https://dotnet.testcontainers.org/custom_configuration/ (Parameter 'DockerEndpointAuthConfig')
---- The following constructor parameters did not have matching fixture data: SqlServerWebApplicationFactory factory
This is the pipeline executing build and tests:
trigger:
- master
variables:
buildConfiguration: 'Release'
jobs:
- job: BuildAndTest
displayName: "Solution Build and Test"
pool:
name: 'Default'
steps:
- task: UseDotNet@2
displayName: 'Use .NET SDK 7.x'
inputs:
packageType: sdk
version: '7.0.x'
- script: dotnet build --configuration $(buildConfiguration)
displayName: 'dotnet build $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: 'Execute Tests'
inputs:
command: test
projects: '**/*Tests/*.csproj'
arguments: '--configuration $(buildConfiguration)'
Is there anything missing in the pipeline yaml file or the integration test configuration?
I'm aware that there are some similar posts like Run dotnet tests in docker which use testcontainers and Testcontainers for .NET error Auto discovery did not detect a Docker host configuration, but our demo project is different since it does not try to run the tests during docker build or docker in docker.