General question on organizing tests: do folks tend to (or is there a convention to) structure the directories and packages in
src/test
to match
src/main
?
a
andylamax
12/21/2023, 1:59 AM
I don't know what other folks "tend to do", But if its a library I don't really structure the packages at all.
If I am writing an application, I do structure my test into similar packages with the main sourcesets
l
Levi
12/21/2023, 2:42 PM
Thanks. I was asking about applications. I went with the convention of structuring dirs and naming packages to match main. Makes it easier for others to navigate even if it's not necessary
b
Big Chungus
12/28/2023, 2:03 PM
This package shadowing mainly comes from java as a hack as it allows accessing package-private members in main from tests (since they both get merged into the same package). Since kotlin does not have package-private visibility, this benefit goes away
Big Chungus
12/28/2023, 2:05 PM
So I'd say it depends on the kind of tests you write. If you define your "unit" in "unit tests" as a target class, then shadowing kinda makes sense still since you have a clear mapping of a test class per source class. For wider "units" in unit tests and integration tests I'd avoid package shadowing and instead structure them by feature.