问题描述:

I am more of a Java guy, and usually the convenient thing with Java is that you can just add a Main method on the fly in various classes to then execute them individually with a raw right-click -> run.

Right now, I have an ASP.NET application, and I am writing a package inside of it that I need to test individually. A little Main function, added on the fly to print things in the console, as described above, is what I would like to have. I tried simply adding one but of course Visual Studio doesn't notice it. At the moment I develop the package in anoher console application to bypass the trouble..

What would you suggest if you see what I mean ?

网友答案:

The common way I do single class tests is by using a unit test framework like nUnit.

This allows me to instantiate and test a class in isolation.

If the class has dependencies, I may also use a mocking framework to mock those out.

网友答案:

A good suite of Unit Tests would probably go a long way to doing what you need.

相关阅读:
Top