Is there an existing issue for this?
Describe the problem
Even though test fixtures are not completely supported by the Android Gradle Plugin (specifically with Kotlin sources) we can still benefit a lot from this feature on JVM modules, and this should definitely be part of Android dev's best practices!
Describe the solution
This would remove a lot of code duplication and prevent unecessary hacks like shared sourcesSet and gradle fixtures modules that could impact build times, especially in large code bases.
In the current state of the code base, it sheds ~1000 lines of code.
At my current company, we chose to use kotlin.Random as receiver for these testFixtures to make them more explicit about their behavior (being random by default), but this can be changed here if needed.
Next steps will be to migrate:
- "test" modules:
:core:data-test, :core:datastore-test, :sync-test
- fakes and test classes like
FakeStringDecoder, TestAuthorsRepository, TestNewsRepository, TestTopicsRepository, TestUserDataRepository
These next steps could already be done, but would need to rewrite classes in Java to be visible, and I don't think this is a path we want to go for this project.
So I guess we'll wait for the full Android/Kotlin support.
Additional context
No response
Code of Conduct
Is there an existing issue for this?
Describe the problem
Even though test fixtures are not completely supported by the Android Gradle Plugin (specifically with Kotlin sources) we can still benefit a lot from this feature on JVM modules, and this should definitely be part of Android dev's best practices!
Describe the solution
This would remove a lot of code duplication and prevent unecessary hacks like shared
sourcesSetand gradle fixturesmodules that could impact build times, especially in large code bases.In the current state of the code base, it sheds ~1000 lines of code.
At my current company, we chose to use
kotlin.Randomas receiver for these testFixtures to make them more explicit about their behavior (being random by default), but this can be changed here if needed.Next steps will be to migrate:
:core:data-test,:core:datastore-test,:sync-testFakeStringDecoder,TestAuthorsRepository,TestNewsRepository,TestTopicsRepository,TestUserDataRepositoryThese next steps could already be done, but would need to rewrite classes in Java to be visible, and I don't think this is a path we want to go for this project.
So I guess we'll wait for the full Android/Kotlin support.
Additional context
No response
Code of Conduct