Huge project tons of classes and directories.
Do I make my unit test project mirror these directories or do I put them all at the root directory?
Somewhat annoying to have to make directory changes and class name changes twice.
You definitely want your unit test directories to mirror the directories of the code under test. It's a mild pain to set up manually, but that pain doesn't last nearly as long as the pain of having all your tests in a pile, or even worse, having them in some different structure than the code under test.
Evidently you're not using Java, or your test code would already have the same package structure as the code under test and the question would be moot. (At least I can't imagine doing it any other way.)
I'd favor having the unit tests in the project directory, to keep them physically close to the code they are supporting. The directory containing the unit tests for one component/package being in that component/package directory, in a specific test
directory, at the same level as the src
directory. This is what I'm doing for C/C++ projects FWIW. The main reason is to be able to compile the component and its unit tests at the same time, to make the unit tests visible (our legacy components do not all have unit tests).
That way, every change made to the directory structure does not have any impact on the test directories structure, as the unit tests are moved along with the production code. Having two parallel directories structures is a form a duplication to me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With