Click here to Skip to main content
13,042,819 members (76,745 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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 18:35pm
Updated 26-Feb-13 18:36pm

1 solution

Rate this: bad
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.
sarahalex@22 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 still confused as to how i am suppose to present a paper on the topic
S. M. Ahasan Habib 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 1-Mar-13 0:46am
thanks :)
S. M. Ahasan Habib 1-Mar-13 0:49am

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 27 Feb 2013
Copyright © CodeProject, 1999-2017
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