Why does Kotlin allow having two classes with same name and package in different folders (i.e.: main and androidTest)?

Viewed 1428

I have discovered that in Kotlin it is possible to have two classes with the same name, in the same package but one of them in the androidTest folder, and when running Espresso tests, it will be this one the one used. This is not possible under Java, and I'm wondering if it is an intended behaviour or it is due to something else.

enter image description here

In the image, AppCollaborator, in Kotlin exist in androidTest and main, AS does not complain, but it does about JavaCollaborator.

The fact is this behaviour is very useful in order to double some classes during test (API, Etc.), but I don't know if I can rely on it.

1 Answers
Related