2 ms·
It is hard to make inline unit tests when the inputs and outputs are really complicated, like the request/reply data structures in a web framework.
by Daniel_Newby 18y ago
It is hard to make inline unit tests when the inputs and outputs are really complicated, like the request/reply data structures in a web framework.
- swombat 18y agoTotally agree, that's why you need good MVC separation and you test those layers separately. The models testing is obvious. What you're referring to there is controller testing. In Rails/Rspec, the way you do that is by mocking/stubbing the models (so you're only testing the controller logic). Then you pass in the parameters that would come in from the web, and check that the controller code (which should be fairly straightforward) behaves appropriately. This article explains this approach quite clearly: http://www.patmaddox.com/blog/2007/9/15/easy-controller-tests-and-expressing-intent-through-expectations http://www.patmaddox.com/blog/2007/9/15/easy-controller-test...