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

I was wondering if there was any decent way, other than NSLog-ing just about
Just wondering about this... I have several separate javascript files, that all contain code
We are about to break our controllers up: actions that return semi-static HTML pages,
This is not a question about how to send emails in .net. I just
I was just wondering this the other day. I am not exactly sure how
Was just wondering how do these sites (and many other softwares that generate flash
just wondering if there is a way to reduce the amount of code needed
Just wondering: I'm trying to set up an adaptive image handler in Coldfusion8, which
Just wondering the best way to replace in place matches on a string. value.replace(bob,
Just wondering, having the following simple code: var object1 = { name: function (){

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.