Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 620107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:43:40+00:00 2026-05-13T18:43:40+00:00

How can i unit test the view of an ASP MVC application? I have

  • 0

How can i unit test the view of an ASP MVC application?

I have tried the mvc contrib test helper…

 _controller.Index().AssertViewRendered();

but this doesn’t actually test the view.

for example i can happily insert some bogus code in the view, and get the dreaded yellow screen of death, without my unit test ever knowing about it.

Is there any estabilished method of doing this? Do i need a mock out the view engine? Does mvccontrib cater to this?

I would have thought this would be a very common requirement, but i can’t find much about it!

Thanks

EDIT
What i’m really after is compile time checking, to ensure that model changes don’t impact the view.

this question contained the instructions to enable build time view compilation which is sufficient for me for now. Compile Views in ASP.NET MVC

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T18:43:40+00:00Added an answer on May 13, 2026 at 6:43 pm

    There are 3 options:

    1. You want to unit test the code in the view. In this case, you have to move the code to the controller, because it’s not the responsibility of the view to have this code.
    2. You want to be sure the view is actually shown in the browser. Use an browser UI testing tool like waitin or selenium. This does not create an isolated test of the view, but of large parts of your application. That sounds like an advantage, but is there any value in an isolated test of a view?
    3. You want to test that code in your view is compilable code. Then compile the code. This can be done in a unit test, by manually calling view.compile or by turning on the view compiler in the build process.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can any one give me the example to unit test the ASP.NET MVC view?
I'm trying to add unit testing to an ASP.NET MVC application I have built.
I am writing unit tests to test an MVC application. How can I validate
I have written a small unit test for my django view .My project structure
I am trying to unit test a razor view (MVC .NET). I want to
The service layer of my ASP.NET MVC 3 application uses AutoMapper to map view
This is my first test for Asp.Net Web Application. We have an Engine consisting
How can I unit test my NSURLConnection delegate? I made a ConnectionDelegate class which
As topic suggested, how can I unit test a function that does not return
Can I use FlexUnit to unit test a File Upload and delete? Are those

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.