Given that I am using EcomDev's PHPUnit framework to write unit tests for my Magento modules, sometimes I come across a controller action that has too much logic within it. It would mean mocking lots of objects and probably providing lots of fixtures to create an effective unit test for methods like this.
Of course, in hindsight the methods should have been written to be smaller and utilize models and helpers wherever possible in small, testable functions, but retrofitting unit tests doesn't really give you that flexibility.
My question is: when situations like this occur, should I:
- Refactor the original controller method to be more modular and easy to unit test
- Battle on through what looks to be an inefficient method to write unit tests for (time to write test greatly outweighs the benefit of having it)
- Skip writing unit tests for this method altogether