What is a Test, and what is an application?
Lets think about how a test fits into the picture...
- A test is not directly applicable to anything the public is concerned about -- they just want it to work
- A test is for developers and usually a business
- Tests can be on the same scale as modules, but are in dichotomic disposition
- If test files can exist side-by-side with its module in a given encapsulating structure, then logically -- in a fractal architecture -- a fraction of a test must also be distributed at the object scale within a given module. (Think, directory|_file|_module|_object -- where
system == component && component == system && (system == system || system == subsystem )
)
That last one is to convey that tests are intrinsically discrete from modules and logically do not complement each other on every scale -- to really understand this, I urge you to study fractals & self-symmetry, Type Theory and Category Theory.
However, application-specifics can drastically alter what options you have...
Coming from a JavaScript perspective, an agnostic one, and even with using an advanced architectural scheme -- it seems that including your tests within the /src
has a potential to complicate your build process. Furthermore, you're creating a less readable logical-bound for other developers when there are multiple, much less lots of, tests within your src directory. You do want to protect and encapsulate you tests, privatizing them to your team members and not anyone interacting with your app publicly.
That said, it still may be worth it to go down this path based upon app specifics -- IF -- you can ensure that it is secure & doesn't create unnecessary complexity, or stifle automation.
Some advanced architectures utilize this approach for purposes of comprehensive encapsulation on discrete scales, but it still may come at a cost to security, automation, and productivity (hence to the business).
As a rule of thumb, use the industry-standard scaffolding:
/app
|-lib
|-src
|-test
.. you probably can't go wrong with this.