Click here to Skip to main content
15,880,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Updated 26-Feb-13 18:36pm
v2

1 solution

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.
 
Share this answer
 
Comments
scarletwitch1990 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 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)
scarletwitch1990 1-Mar-13 0:46am    
thanks :)
S. M. Ahasan Habib 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900