lundi 27 janvier 2020

TDD: When testing a ReST API Controller is it prudent to test all actions (create, update, get, delete, etc) all in a single test-file?

This is clearly a practical question. Internet wisdom suggests logically organizing tests for maintainability. When it comes to ReST API Controllers one could include all integration-tests for all actions of the controller in a single file.

Assuming we have 4 CRUD actions per controller with an average of 6 tests per action we are bound to end up with at least 24 tests in one file. In industrial-grade web-servers I suspect that this number would baloon way further upwards.

The thing is that these actions even though they are part of one class (controller) they are complex and orthocanonical (different resources/artifacts/mockups needed to test each group etc).

I'm having a hard time coming to terms that all these tests should be placed in one file given the fact that they are testing almost entirely different things and can be placed in 4 separate files. Isn't this more aligned with the spirit of TDD afterall?

Is my intuition misplaced?

Aucun commentaire:

Enregistrer un commentaire