C
C#3mo ago
Cpt. Reis

Unit/Integration testing - what are good approaches?

hey! i'm working in my first C# / .NET project and i'm excited to learn new stuff (having Java/Spring background), as .NET is a whole new experience for me. in the former project, we had really good test setup - a ton of integration tests covering everything, working with test containers to build a database instance for the tests. tests were run on each PR via git actions, which guaranteed working tests on the main branches. in my new project, we're in the "forming" phase, so it's not that consistent yet from a technical perspective. meaning, we're wrapping our heads around a solid setup. and i wonder about a few points: - would you prefer unit or integration tests, and why? - how can the test setup be done effieciently in .NET - so that we spin up a database and run the migrations there for example, to rebuild the correct structure? - do you have some general tips for testing in .NET for me? thankful for your thoughts!
1 Reply
Pobiega
Pobiega3mo ago
Unit testing for pure functions, integration tests for everything else. You can get set up testing databases via something called TestContainers General tips, use XUnit and fluent assertions