Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If you use type annotations you basically already do that. The type (assertions) are mixed right into the business code! And from there it's not much of a leap to keep the unit tests close by.

Integration tests and other, larger tests should still be kept somewhere else, because they often not test a single component (or a single module) but a larger part of the whole application which is harder to pinpoint in the filesystem. So most people put those tests under a top-level tests/ folder inside the project.



> If you use type annotations you basically already do that. The type (assertions) are mixed right into the business code! And from there it's not much of a leap to keep the unit tests close by.

Unit tests are about testing behavior, not types. Using type annotations has nothing to do with testing.

Putting tests right along the source code is a matter of convenience thus an opinion.

In some languages like Go it is even "good practice".


Good types express behaviour.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: