Welcome Guest, Not a member yet? Register   Sign In
Implementing Validation and Unit Testing Question
#1

[eluser]_TubbZ_[/eluser]
Hello,

I am currently performing all my validation in the respective controllers which seems to be the CI standard using the Form_validation library. But from my interpretation of MVC is that the model should handle this and the controller should be just controlling the models (Fat Models, Skinny Controllers). The reason for asking is I am currently writing some unit tests to hammer my application and the testing library (TOAST and I tried a few others) cannot offer any tests on the controllers. So effectively my unit tests aren't that useful to test expected results. Although I can assume that the Form validation does what its supposed to do I really would prefer to test everything properly without any assumptions.

So should i move validation into the models? Or am i missing something here!

Thanks!!!
#2

[eluser]jalalski[/eluser]
I think it is two different things. Form validation is there to provide fast feedback to users that their input is not complete and for testing this I use Selenium test cases.
Unit tests, in my view, are for testing the backend of the site without concern of the graphical front end.
I tend more to Skinny Models, Fat Controllers and so form validation naturally belongs in the controller. If you think of the form validation stuff as being more of a View thing, then I don't see any reason for it to be in the Model.
#3

[eluser]_TubbZ_[/eluser]
Ooh Selenium test cases sounds more like what I need. Thanks, will look into it.




Theme © iAndrew 2016 - Forum software by © MyBB