Put unit tests with the code they test
dylang opened this issue · comments
Instead of putting unit tests to their own subtree, put them with the files they test.
For example:
* services
* cache
* cache1.js
* cache1.test.js
* models
* model1.js
* model1.test.js
This way when we're updating code it's clear that there is a test that will need to be updated first. The tests also act as documentation and show use cases.
I think you'll find tests to be more well-respected here instead of neglected or an afterthought.
Your suggestion makes sense.
The AngularJS generator of Yeoman, AngularJS Seed and the AngularJS project uses different directory for the tests.
ng-boilerplate use model like the one suggested by you.
I think we should collect more opinions for this issue and issue 9 before making further steps.
I prefer putting unit test code with the files they test as well like the way ng-boilerplate do it. Beside easier drag and drop ability, looking for all code belong to one functionality/module will be much more easier; all code, unit test code, template and css/less/sass will be in one place.
Agree on putting tests to the same folder with code. When application grows it's much easier to work this way.
I would just suggest to name them cache1.spec.js instead of cache1.test.js, as it is more common naming convention.