DEV Community

Thang Chung
Thang Chung

Posted on • Updated on

.NET 8 Integration Tests on Podman Desktop (Windows 11 - WSL2 Ubuntu 23)

Context: we have to work on a project that requires running .NET 8 Integration Tests (TestContainers) on Windows 11 WSL2 (Ubuntu) enabled.

Why do we need it?

We can install docker on WSL2 - Ubuntu and run the same thing like that. But the reason I struggled to set up and debug the .NET project with integration tests (you know how debugging is important for .NET developers, right? We can set up to debug to point to WSL in Visual Studio 22, but it is quite tricky for me actually - the absolute project path needs to be set in launchsettings.json => check it, and from my POV, if you can debug it on Visual Studio 22 or Visual Code that would be great for our developers.

Why do we need Podman Desktop?

Because in my company the license of Docker for Desktop could cause a problem of cost for many developers (our customers prefer to use OSS software). So you might not need it in your situation, that's fine.

After doing much research on how to run integration tests with .NET 8 (to be honest, I have done many parts in .NET 3.1, .NET 6, and .NET 7; but with .NET 8 many things changed so I had to re-visit it again for this project - but luckily works now), I will have another blog post on this topic later. The source code from this post is the forked one from the excellent repo from my best friend (Kim Cu) at Come and check it out if you are interested in doing integration tests with .NET. It was worth it.

Now we focus on how to run these kinds of integration tests on Windows 11 with Podman Desktop which we think is very cool due to the license of Docker for Desktop so many people would like to run some kind of alternative Docker daemon on Windows (or Mac).

Let's get started. After installing Podman Desktop at We could run it up, and sometimes you get an error can't run because of incompatible with the docker daemon. No worry just type wsl --shutdown and it should work.

And then, we could get another problem like we couldn't pull the docker image down to your machine just like below

System.AggregateException : One or more errors occurred. (Docker API responded with status code=InternalServerError, response={"message":"lookup Temporary failure in name resolution"}
) (The following constructor parameters did not have matching fixture data: PersonalServiceTestCollectionFixture testCollectionFixture)
Enter fullscreen mode Exit fullscreen mode

Follow the guidance at <== This trick is very cool then

Now, do one more step, check your .wslconfig file, and make sure it is as below

# kernelCommandLine=systemd.unified_cgroup_hierarchy=1 cgroup_no_v1=all # comment out it because cgroup v2 might cause the problem

# autoMemoryReclaim=gradual # This is a trick as well, see
Enter fullscreen mode Exit fullscreen mode

Now, you can run the .NET 8 Integration Tests with Podman Desktop as below

> git clone
> cd setup-dotnet-test-projects\src\Services\PeopleService\DNP.PeopleService.Tests
> dotnet test --collect:"XPlat Code Coverage"
Enter fullscreen mode Exit fullscreen mode

It should work. It will start 2 containers: Postgresql and RabbitMQ, then run the integration tests on these containers, finally, it will reclaim and remove everything. The artefacts we want are TestResults\6816ea65-b172-4f10-93a0-a70851cae31a/coverage.cobertura.xml, and we will use it to generate the code coverage. That is what we want.

Happy hacking. Let me know how cool is it <3

Top comments (0)