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 231981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:58:43+00:00 2026-05-11T19:58:43+00:00

Stephen Walther recommends that you should provide explicit view names when you want to

  • 0

Stephen Walther recommends that you should provide explicit view names when you want to unit-test them.

I definitely want to test them, but I’m curious whether or not this recommendation is still valid with the release of 1.0.

In the NerdDinner tutorial the tests just check if the viewResult is null. They don’t explicitly specify the viewName, which is therefore empty.
I would like to remove the view-names provided as strings in the actual code, but these checks seems less useful to me though…
(I can’t even think of a scenario where the viewResult does return null?!)

  • 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-11T19:58:43+00:00Added an answer on May 11, 2026 at 7:58 pm

    There are really two separate questions here. The first is whether or not anything has changed in the MVC framework since Stephen Walther wrote the recommendation which would change the recommendation. The answer to that question is “no.”

    The second question is whether or not the recommendation is a good practice. I’m going to disagree with Stephen Walther, here. His example is a bit strange. His unit test for the “Index” action attempts to assert that the action returns an explicit view name, when clearly it does not. If I wrote this unit tests, I would instead assert that the view name is equal to empty string. Then the unit test would pass. Instead of asserting that the action specifies a view of a certain name, a unit test would then effectively assert that the action specifies that the view have the same name as the action. This is a legitimate thing to test.

    One of the guiding principles behind the MVC framework is convention over configuration. In other words, you should not be required to specify anything which is just the usual default value. The default value of the view name is the same as the action name. The documented behavior of the WebFormsViewEngine is to look for a view with the same name as the action unless a separate view name is specified. Not specifying a view name, therefore, is the same as specifying “use the default view name.”

    Therefore, I do not think it is a good idea to specify a view name which is the same as the default, and I do not think that using unit testing is a good reason to violate this convention.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am learning MVC from Stephen Walther tutorials on MSDN website. He suggests that
In another question , Stephen C says: A second concern is that there are
I have the following in testng.xml ... <parameter name=Empl_Name value=Stephen /> <test name=Employee Search
Basically if I want to transform a name from stephen smith to Stephen Smith
I have some text that is passed dynamically, but the design of the text
I'm using Stephen Walther's paging tip #44 ( http://stephenwalther.com/blog/archive/2008/09/18/asp-net-mvc-tip-44-create-a-pager-html-helper.aspx ) on my app and
I watched a pdc session by Stephen Walther and in the presentation he was
I am currently learning ASP.NET MVC and I have followed Stephen Walther's tutorial: ASP.NET
How would I go about using Stephen Celis' fantastic SCListener singleton? ( http://stephencelis.com/2009/03/02/now-i-just-need-an-audience.html )
I saw a comment on Ben Nadel's blog where Stephen Rushing posted a loader,

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.