Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: UnitTesting MVC4
during one of my lectures in unit testing, my professor stated that testing a controller action comes under functional testing, and that the best practice to test the controller is to unit test the various independent functions that we are using in it like the service layer functions.
we are suppose to write a paper on the above justifying it and stating examples.
Is it true that controller actions come under functional testing, if it does then why is it recommended to test controller action result?
Can anyone help me here?
Posted 26-Feb-13 19:35pm
Edited 26-Feb-13 19:36pm
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I want to say my personal opinion on that. Many experts may agree/disagree. So need there opinion 2.
Controller Action test is not functional testing. It is part of UI testing. Which will be part of functional which will be non functional testing depends on the parpose of original method/behaviour. We know that Controller action method's responsibility is it receive user input and call appropriate model for data/logic and render its responsible view. So i think main responsibility is delegate to appropriate view(ActionResult). In that sense i think it is not part of functional testing.
  Permalink  
Comments
sarahalex@22 at 27-Feb-13 2:31am
   
thanks for clearing it out, S. M. Ahasan Habib, but he(my professor) says that it is a web request that a controller renders and that it comes under functional testing(more-or-less) due to the many dependencies one might use inside the controller....im still confused as to how i am suppose to present a paper on the topic
S. M. Ahasan Habib at 27-Feb-13 3:14am
   
If you write business logic inside controller action then no body can protect you, in that case you can call action testing as functional testing, but it will violated of mvc design pattern principle. So functionality should be inside Model/Business component and Model test will be called functional testing. (again my personal opinion)
sarahalex@22 at 1-Mar-13 0:46am
   
thanks :)
S. M. Ahasan Habib at 1-Mar-13 0:49am
   
welcome

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 215
1 George Jonsson 175
2 Kornfeld Eliyahu Peter 159
3 PIEBALDconsult 110
4 Richard MacCutchan 85
0 OriginalGriff 6,080
1 DamithSL 4,648
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,624
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 27 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100