I’m currently doing some trainee work & looking for a bit of advice.
I’ve been set a pretty simple task of writing some unit tests for a service application in C#. The service mainly has methods which query and look up and SQL database for various things. I’ve been asked to write unit tests for the majority of these methods and other things like simply checking the connection and stuff. I’ve been told to keep it simple and probably just write the tests in a Console application. I’m wondering what the best way to go about this would be?
Would simply calling the methods from a console app with hardcoded input be suitable? Then just check what the output is & write whether is passes in the console? Or is this too simple and nasty?
You can run both MSTest and NUnit tests from the command line and in my opinion that would be far more preferable than writing your own test runner from scratch. Concentrate on writing quality tests, not the scaffolding required to execute them and deliver the results.
I would suggest it’s as simple to do it “properly” as it is to craft your own solution.
Note though that tests connecting to the database are integration tests, not unit test.