开发者

ASP.net/C#: How compile classes in App_Code so that can be run from command line for unit testing?

开发者 https://www.devze.com 2023-01-09 15:37 出处:网络
I have several class files in App_Code in an ASP.net website running in Microsoft Visual Studio 2005 Professional.

I have several class files in App_Code in an ASP.net website running in Microsoft Visual Studio 2005 Professional.

In liu of using a full unit test suite I just want to somehow compile those project-wide classses into an .EXE so that I can nightly run unit tests on them.

I do know how to create a separate C# library project consisting of th开发者_StackOverflow社区ose files and how to include them into my website--but that is not desirable--I don't want to give up the ability to make on-the-fly code changes of those library classes when running the website in the debugger. As far as I know .Net debugger isn't powerful enough to modify code in included libraries with instant auto re-compilation on page re-load.

So, I want my cake and eat it, too:

  1. Command-line unit testing of website class files in App_Code directory
  2. Being able to modify those class files w/o stopping/re-starting the web debugger.

Is it possible to have both?


You should put the code in an altogether separate class library/assembly, then reference it from your web project and the command-line utility. As far as I know, it makes no difference where you modify your code, when stopped in the debugger. Never had problems myself.

Hope that helps.


Your project is under source control, right? Right? In that case, you can use your source control system to include a link to your asp.net project's app_code folder as part of a separate unit testing project. The exact linking mechanism varies by source control platform, but done right it means there's exactly one instance of your App_Code folder in source control that's visible from two different projects. This way, everything stays up to date.

This has the advantage of allowing you to keep easy, uncompiled code right there just like you always have, but still making the code available for testing.

0

精彩评论

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