Is it easier to place test files right next to the source files they test (in the same src
directory), or should a separate tests
directory with a mirror hierarchy be created?
Having them in the same folder seems to make life easier when it comes to maintenance, but also crowds the source directories.
Option 1: Directory structure when having separate folders for source and tests:
- src
+-- item.ts
`-- util
+-- helper.ts
- test
+-- item.test.ts
`-- util
`-- helper.test.ts
Option 2: Directory structure when having both types of files in the same directory:
- src
+-- item.ts
+-- item.test.ts
`-- util
+-- helper.ts
`-- helper.test.ts
I used to always go with option 1 until trying out angular-cli
and having it generate code files alongside the test files as in option 2, which made me rethink the whole thing.
Aucun commentaire:
Enregistrer un commentaire