This is an area of opinion...so know that the following is a bunch of opinion, I don't mean to present it as fact. Since I am presenting opinion, I want to apologize in advance should I fail to appropriately express my opinion and cause offense. I mean none. I also don't want to presume too much, so if define things you are well versed in, I am very sorry, I simply don't want to make assumptions that might reduce the clarity in my statements.
bq I'm not well-versed in maven, but wouldn't it be cleaner to move all the tests to itests?
I don't think so. Too be clear, I don't like the way this is broken up but compared with the old ant based build, I am willing to live this 100 times over. That old build had degraded into "a fate worse than death". Ideally we would re-write the "unit" tests in itest into true unit tests, as defined below, and move them back into the regular build.
I think it might become confusing when adding new tests if the tests for a package are split into different locations.
I would strongly suggest that no new tests should be added to itests. If a new "unit" test is being added there it's because it is not in fact a unit test.
Often you have two kinds of tests:
- unit tests - tests that individually only test a "small" piece of functionality making them extremely fast
- integration tests - cross module testing e.g. test that test the integration of one or more components
I strongly believe and it's maven's assumption that unit tests live with the code it's testing (the pattern is module/src/main/java, module/src/test/java). This is good because:
- After making changes within a module you can do sanity tests by easily running the tests within only that module
- Allowing unit tests to import any dependency results in what are supposed to be "unit" tests degrading to in integration tests
Because the previous hive build was monolithic it wasn't easy to make changes within a single module and then run sanity tests on only that module. Additionally because any project could use nearly any dependency, a large number of what should have been "unit" tests degraded into integration tests.
When I say "degrade into an integration tests" I mean that a unit test should test a specific piece of functionality and be extremely fast, generally sub-second. In my experience, if a test takes more than one second to two seconds it's either a poorly written unit test, a poorly written class, or an integration test. Often it's because infrastructure which is not being tested is instantiated, not mocked. e.g. starting a server as opposed to mocking a server.
TL; DR: I'd love to move the tests in itest back to their owning module, it just requires some work to do so. Huge +1 to anyone willing to take on the challenge!