开发者

Should I write unit tests as console apps first?

开发者 https://www.devze.com 2023-01-15 05:11 出处:网络
I\'m debugging a set of WCF services. Initially, I created some unit tests, but since I\'m using threading I often receive \"Aborted\" or \"Stopped\" tests without any clear explanation why (this is a

I'm debugging a set of WCF services. Initially, I created some unit tests, but since I'm using threading I often receive "Aborted" or "Stopped" tests without any clear explanation why (this is a known bug in Visual Studio).

I found it extremely challenging开发者_开发问答 to debug the services when I can't even read the log output, so I quickly wrote a custom Assert class and converted all unit tests to console applications. This way, I was able to fix a huge number of simple problems immediately that were hard to impossible before.

So I'm wondering if it is a good idea to write unit tests as (fully automated) console apps first and convert them to real (executes when launching unit tests in VS) tests later.


if you want to stick to the stand alone console app you can have a one fits all aproach: Change

  • the application type of the MsUnitTest (or NUnitTest) to "Console application"
  • add a public static void Main() that call your unittests you are interested in.

This exe is can run on its own or it runs in the unittest-ide.

I prefer a standalone consolerunner as described in how-do-i-use-mstest-without-visual-studio

0

精彩评论

暂无评论...
验证码 换一张
取 消