简体   繁体   中英

testing Razor views in ASP.Net MVC

We have a quite large web-application in ASP.Net MVC, which has a good amount of views. Starting the application takes quite some time, due to application initialisation logic, etc.

Is there any way to 'test' a view, without actually having to 'start' the web-application in Visual Studio? The idea is to be able to mock the Model and pass in a custom model, and check that the view renders correctly. The view is also using Master Layouts, so that would be something that needs to be considered. We are wasting a lot of time going through the start/stop process of the application, and would like to see if there is actually any other way forward.

Hmm. We use Selenium WebDriver with Specflow to test the best part of our site. We do this as part of a full regression test suite that we can run at the flick of a button with our CI server (Team City).

You may also want to consider using PhantomJS, http://phantomjs.org/ . This will give you faster results as there's not browser involved.

Other than that, I don't know of anything built in to/on top of MVC specifically that can aid you.

If you've a large volume start by breaking your site down and workout what the most important parts are. I would look to focus on those first to validate your testing process.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM