My questions is mostly about testing methodology. I am working for an organization which practices TDD. We are using AngularJS and hence its full testing stack - Jasmine for unit tests and Protractor for e2e testing.
When developing a feature our process begins by first writing a failing e2e tests and then writing the feature our using TDD. The tests are only written for public methods (be it for controller/directives/services). The product it self does not contain any complex logic (besides couple of exceptions). Recently we began discussing the fact that there is no point in writing unit tests for controllers, as they are exposing functionality, 100% of it is exposed to the view and it tested using e2e tests anyway and that the unit tests are e2e tests are overlapping. At first we all agreed, but then this decision opened a pandora box. After all, the same thing could be said about directives aswell. So why test them aswell? Then the question of services came up. Most of them (98%) simply make a back-end call and return the response. So why no simply mock httpBackend and test the services while testing the controllers, which are tested through e2e.
You get the drift....
I do see benefit in doing both unit tests and e2e tests, despite them practically overlapping mainly for instant feedback and "executable documentation". What are you practicing? Do you see other benefits and is "juice worth the squeeze" - is worth writing overlapping tests for the simplest of implementations just to get those two benefits?
Aucun commentaire:
Enregistrer un commentaire