I'm trying to test a class (a controller) that doesn't need to run inside the asp.net environment.
But when I run the test, cassini starts.
How can I avoid the cassini load?
Thanks
I'm trying to test a class (a controller) that doesn't need to run inside the asp.net environment.
But when I run the test, cassini starts.
How can I avoid the cassini load?
Thanks
Your controller does need the asp.net environment, it is the handler for your requests. You can set your IDE to use IIS instead. Click on the properties page of your project and on the web tab you will see a Use IIS radio button which will let you set up a virtual directory. Then no more cassini.
If you have used the create unit tests feature in Visual Studio then it will have made a test like this
[TestMethod()]
[HostType("ASP.NET")]
[AspNetDevelopmentServerHost("C:\\working\\MDTest\\MvcApplication1", "/")]
[UrlToTest("http://localhost:1169/")]
public void AccountControllerConstructorTest()
{
//Implementation
}
The UrlToTest attribute is what is causing cassini to start. As I stated above, your controller does need the asp.net environment because it is an http handler, so it needs to be invoked using http in order to test it. If you just don't like cassini (fair enough) then you are still going to need IIS to get it to work.
If you right click on your web project, then follow the instructions at the top of this post, the Create Unit Tests feature will produce this
[TestMethod()]
[HostType("ASP.NET")]
[UrlToTest("http://localhost/MvcApplication1")]
public void AccountControllerConstructorTest()...
Which runs without cassini :)
Cassini should only run if you debug or run your project (i.e. by pressing F5 or Ctrl-F5), not when you execute your unit tests. You can modify what happens when you press F5 by viewing the properties for you ASP.NET project and selecting the Web tab. You haven't specified how you execute your tests, but both the Visual Studio unit testing framework and frameworks like NUnit will run your tests in a separate process that is not Cassini. If you instead have say your own console application project to execute your tests you should make sure that you have set this project as the StartUp project. Then pressing F5 will execute your test console application and not Cassini.
If you run your tests in debug mode cassini will start. If you run your tests without debug mode then it will not.