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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:53:45+00:00 2026-05-14T22:53:45+00:00

I was just wondering how others are going about testing controller actions in asp.net

  • 0

I was just wondering how others are going about testing controller actions in asp.net mvc? Most of my dependencies are injected in to my controllers so there is a not a huge amount of logic in the action methods but there may be some conditional logic for example which I think is unavoidable.

In the past I have written tests for these action methods, mocked the dependencies and tested the results. I have found this is very brittle and a real PITA to maintain. Having ‘Expect’ and ‘Stub’ methods everywhere breaks very easily but I don’t see any other way of testing controller actions.

I actually think it might be easier to test some of these manually! Anyone have any suggestions? Perhaps I am missing something here?

Thanks

Imran

  • 1 1 Answer
  • 3 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-14T22:53:46+00:00Added an answer on May 14, 2026 at 10:53 pm

    i don’t think i’ve writtin a single test for a controller because all of my logic is elsewhere. Like you say the controllers have a minimum amount of code in them and any logic in them is so simple that it really doesn’t bear a whole test strategy.

    i prefer to give my models a whole lot of tests as well as any supporting code like DTL’s and data layers etc.

    i think i’ve seen some people mock up their copntollers, pass in the expected models and look at the resultant output but i’m not sure how much that gives you.

    i think if i were to test a controller i’d only really test the post actions to ensure that what is being given to my controller is what i’m getting in my model as well as testing (security). But then I have security in a number of places of varying levels.

    but all that is integration testing more than functional. functional i do elsewhere like i said earlier.

    then again, if it’s worth writing then it’s worth testing huh? I guess you need to decide what and where the breakable bits are and how you want them tested.

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

Sidebar

Related Questions

Just wondering if anyone knows of a way to implement a Typed Nullable Type
I was just wondering if there was a possible way to add a custom
I was wondering is there any tutorial out there that can teach you how
I was wondering if anyone could help me solve how to view $_POST requests.
It's bothering me what delete [] actually does, so I just tried some code
Currently, when I start vi in a terminal window within screen, the vi program
I've set up several models, as you'll see shortly in my code. These models
I'm currently working on an iPhone app that is fairly data intensive. It downloads
I like the LLVM idea. To be honest, I do not much care for
I am making a <a href="http"//www.woot.com">woot app, and I am using the API .

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.