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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:15:34+00:00 2026-05-16T04:15:34+00:00

Recently I’ve started to write on asp.net mvc framework. I have a problem. I

  • 0

Recently I’ve started to write on asp.net mvc framework. I have a problem. I can’t understand meaning of the unit tests. Let’s see on example

public class HomeController : Controller 
{ 
    public ActionResult Index() 
    { 
        ViewData["Message"] = "Welcome to ASP.NET MVC!"; 
        return View(); 
    } 

    public ActionResult About() 
    { 
        return View(); 
    } 
} 

and the tests

[TestMethod] 
public void Index() 
{ 
    HomeController controller = new HomeController(); 

    ViewResult result = controller.Index() as ViewResult; 

    ViewDataDictionary viewData = result.ViewData; 
    Assert.AreEqual("Welcome to ASP.NET MVC!", viewData["Message"]); 
} 

[TestMethod] 
public void About() 
{ 
    HomeController controller = new HomeController(); 

    ViewResult result = controller.About() as ViewResult; 

    Assert.IsNotNull(result); 
} 

I have a questions.

1) In what case, method About won’t return View?

If there is no view About, method will return nothing. It’ obviously
It is simple to click “Run”, type in browser “Home/About” and see result. Without any unit tests.
It’s more faster than creating unit tests, running them…

2) In what case, method About return diffrent ViewData?
Check yourself. It’s faster than unit tests

Let’s see Account controller’s test

Using this test we can check log in success. But it’s more simple to run the application and type login/password manually

Please describe advantages of unit tests. In unit tests we’ll enter data manually. So why can’t we type it manually?
Разъясните пожалуйста в чём их плюс. Если всё равно все тестировочные данные набиваешь руками не проще ли самому всё проверить

  • 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-16T04:15:35+00:00Added an answer on May 16, 2026 at 4:15 am

    You’re right, these are Captain Obvious unit tests. In practice you’ll write more complicated unit tests than this.

    But it’s more simple to run the application and type login/password manually

    Once, maybe. But after every build? The point is automation: once you’ve built up a huge unit test suite you can use the test framework to execute it all automatically to catch regressions introduced with the last set of changes.

    And then there’s test-driven-development, etc. I expect there are good “Why unit test?” essays out there with much more.

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

Sidebar

Related Questions

Recently I have been investigating the possibilities of caching in ASP.NET. I rolled my
Recently, I've been dealing with an error with accessing MAPI via the .NET framework
Recently I have been dealing with windows LogonUser API. The LogonUser api returns different
recently I started using storyboard and I've the following situation: I want to set
Recently we have released our product. Our team decided to preserve the source code
Recently two users of our software from the same company started experiencing random closures
Recently I discovered a problem on the midas and I fixed it, the problem
Recently i am making an app on facebook. So i have use facebook api.
Recently I am working on selenium webdriver 2.0 (developing automation framework). As per requirement
Recently I tried to write a simple compiler on the linux platform by myself.

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.