Create a wiki page for Testcontainer #1132
Labels
No labels
_CRITICAL_
API
app
backEnd
Blocked, waiting for further changes
bug
cleanup
close
design
duplicate
enhancement
feature request
frontEnd
help wanted
invalid
low priority
needs input
needs review
project documentation
question
research
reviewed
script
security
SQL
style
testing
topLevel
wontfix
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Andras/BoundlessFlowCampus2K#1132
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Create a wiki link to explain how to use testcontainer and explain how they work
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
Requesting review from @b24krila
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:
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.
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
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
Färdig med ändringar
I have gone over the update wiki and I believe everything looks good and the issue can be closed.