Create a wiki page for Testcontainer #1132

Closed
opened 2026-05-25 10:41:32 +00:00 by a24hirsa · 6 comments
Collaborator

Create a wiki link to explain how to use testcontainer and explain how they work

Create a wiki link to explain how to use testcontainer and explain how they work
Author
Collaborator

created a wiki page for test containers and how it is used together with xUnit and web hosting a test server

https://git.webug.se/Andras/BoundlessFlowCampus2K/wiki/Integration-testing-utilizing-testcontainers%2C-xUnit-and-ASP.NET-core-web-testservers

created a wiki page for test containers and how it is used together with xUnit and web hosting a test server https://git.webug.se/Andras/BoundlessFlowCampus2K/wiki/Integration-testing-utilizing-testcontainers%2C-xUnit-and-ASP.NET-core-web-testservers
Collaborator

Requesting review from @b24krila

Requesting review from @b24krila
Collaborator

Review

Overall the wiki page is good and provides a solid practical overview of how Testcontainers are used together with xUnit and ASP.NET integration testing. The examples and structure in the wiki make the general workflow understandable and easy to follow.

A question that comes up is in this part:

Although the reasoning for using testcontainer with xunit and ASP.NET core is to do integration tests on real databases and not in memory databases, we can still do unit tests if we want thanks to xUnit. If unit tests are the only tests planned for a service/api/anything that will need testing then utilizing testcontainer is overkill and mostly a time loss, still possible but wholly unnecessary. But if integration tests are planned then unit test using xUnit is a very good way of testing connection to the database trough http to ensure that the containers and webhost are configured correctly

Is this truly considered a unit test since it seems like it would use external dependencies (HTTP, database, containers) and then instead be classed as an integration test or am I wrong?

another question is from this example:

_postgres = new PostgreSqlBuilder("postgres:18.3-alpine3.23") //found in postgres dockerfile
           .WithImage("postgres:15-alpine")

it seems that the example uses two different versions of postgreSql so that leads to confusion about which is actually in use.

Conclusion

The wiki looks good for the most part, I have commented on the parts I am slightly confused about and would like the developer opinion before saying this issue can be closed. Otherwise the structure is good and easy to follow and the wiki goes into detail about how it works and why we use it.

### Review Overall the wiki page is good and provides a solid practical overview of how Testcontainers are used together with xUnit and ASP.NET integration testing. The examples and structure in the wiki make the general workflow understandable and easy to follow. A question that comes up is in this part: **Although the reasoning for using testcontainer with xunit and ASP.NET core is to do integration tests on real databases and not in memory databases, we can still do unit tests if we want thanks to xUnit. If unit tests are the only tests planned for a service/api/anything that will need testing then utilizing testcontainer is overkill and mostly a time loss, still possible but wholly unnecessary. But if integration tests are planned then unit test using xUnit is a very good way of testing connection to the database trough http to ensure that the containers and webhost are configured correctly** Is this truly considered a unit test since it seems like it would use external dependencies (HTTP, database, containers) and then instead be classed as an integration test or am I wrong? another question is from this example: ``` _postgres = new PostgreSqlBuilder("postgres:18.3-alpine3.23") //found in postgres dockerfile .WithImage("postgres:15-alpine") ``` it seems that the example uses two different versions of postgreSql so that leads to confusion about which is actually in use. ### Conclusion The wiki looks good for the most part, I have commented on the parts I am slightly confused about and would like the developer opinion before saying this issue can be closed. Otherwise the structure is good and easy to follow and the wiki goes into detail about how it works and why we use it.
Author
Collaborator

Although the reasoning for using testcontainer with xunit and ASP.NET core is to do integration tests on real databases and not in memory databases, we can still do unit tests if we want thanks to xUnit. If unit tests are the only tests planned for a service/api/anything that will need testing then utilizing testcontainer is overkill and mostly a time loss, still possible but wholly unnecessary. But if integration tests are planned then unit test using xUnit is a very good way of testing connection to the database trough http to ensure that the containers and webhost are configured correctly

Is this truly considered a unit test since it seems like it would use external dependencies (HTTP, database, containers) and then instead be classed as an integration test or am I wrong?

This is fair and when looking deeper it is more of an integration test then a unit test. I was going of on the fact that when checkign the http you only really need the postgres, but its still using the webhost to send the message so its not actually testing something isolated in the postgres or giving a function a fake value to test if it will fail or not by utilizing mock in memory elements. Im going to remove that final sentance but keep the rest as its a good reminder to not go for unit tests when using testcontainers

another question is from this example:

_postgres = new PostgreSqlBuilder("postgres:18.3-alpine3.23") //found in postgres dockerfile
.WithImage("postgres:15-alpine")

it seems that the example uses two different versions of postgreSql so that leads to confusion about which is actually in use.

Det här va bra fångat som jag missade, det som beskrivs är olika versioner av postgresen och eftersom jag skrev WithImage biten så sätts postgres versionen till 15 istället för att vara 18.3 (eftersom withimage vinner alltid i det här sammanhanget vilken version av PostgreSQL vi skapar i containern) som matchar våran rikitiga databas, med denna typen av kod kan små beteende skillnader existera som leder till att testen inte är 1 till 1 med den riktiga databasen. Jag kommer uppdatera båda wiki'n och koden för att fixa buggen och matcha

> Although the reasoning for using testcontainer with xunit and ASP.NET core is to do integration tests on real databases and not in memory databases, we can still do unit tests if we want thanks to xUnit. If unit tests are the only tests planned for a service/api/anything that will need testing then utilizing testcontainer is overkill and mostly a time loss, still possible but wholly unnecessary. But if integration tests are planned then unit test using xUnit is a very good way of testing connection to the database trough http to ensure that the containers and webhost are configured correctly > > Is this truly considered a unit test since it seems like it would use external dependencies (HTTP, database, containers) and then instead be classed as an integration test or am I wrong? This is fair and when looking deeper it is more of an integration test then a unit test. I was going of on the fact that when checkign the http you only really need the postgres, but its still using the webhost to send the message so its not actually testing something isolated in the postgres or giving a function a fake value to test if it will fail or not by utilizing mock in memory elements. Im going to remove that final sentance but keep the rest as its a good reminder to not go for unit tests when using testcontainers > another question is from this example: > > _postgres = new PostgreSqlBuilder("postgres:18.3-alpine3.23") //found in postgres dockerfile > .WithImage("postgres:15-alpine") > > it seems that the example uses two different versions of postgreSql so that leads to confusion about which is actually in use. Det här va bra fångat som jag missade, det som beskrivs är olika versioner av postgresen och eftersom jag skrev WithImage biten så sätts postgres versionen till 15 istället för att vara 18.3 (eftersom withimage vinner alltid i det här sammanhanget vilken version av PostgreSQL vi skapar i containern) som matchar våran rikitiga databas, med denna typen av kod kan små beteende skillnader existera som leder till att testen inte är 1 till 1 med den riktiga databasen. Jag kommer uppdatera båda wiki'n och koden för att fixa buggen och matcha
Author
Collaborator

Färdig med ändringar

Färdig med ändringar
Collaborator

I have gone over the update wiki and I believe everything looks good and the issue can be closed.

I have gone over the update wiki and I believe everything looks good and the issue can be closed.
Sign in to join this conversation.
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Andras/BoundlessFlowCampus2K#1132
No description provided.