Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR]: Migrate project to testFixtures #451

Open
2 tasks done
SimonMarquis opened this issue Nov 19, 2022 · 4 comments
Open
2 tasks done

[FR]: Migrate project to testFixtures #451

SimonMarquis opened this issue Nov 19, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@SimonMarquis
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

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

  • I agree to follow this project's Code of Conduct
@SimonMarquis SimonMarquis added the enhancement New feature or request label Nov 19, 2022
SimonMarquis added a commit to SimonMarquis/nowinandroid that referenced this issue Nov 19, 2022
SimonMarquis added a commit to SimonMarquis/nowinandroid that referenced this issue Nov 19, 2022
SimonMarquis added a commit to SimonMarquis/nowinandroid that referenced this issue Nov 19, 2022
SimonMarquis added a commit to SimonMarquis/nowinandroid that referenced this issue Nov 19, 2022
SimonMarquis added a commit to SimonMarquis/nowinandroid that referenced this issue Nov 19, 2022
SimonMarquis added a commit to SimonMarquis/nowinandroid that referenced this issue Nov 19, 2022
@JolandaVerhoef
Copy link
Collaborator

This looks like an interesting addition, however I'd like to wait for support by Jetbrains (through https://youtrack.jetbrains.com/issue/KT-50667) before adding this to the project.

@SimonMarquis
Copy link
Contributor Author

Just to clarify, testFixture are officially supported.
The only bit that is not yet supported is exposing Kotlin sources from an AGP (com.android.application or com.android.library) module.
But I can understand if we don't want to include this feature until it is completely supported 👍

@yogurtearl
Copy link

Blocked by this issue: https://issuetracker.google.com/issues/259523353

@SimonMarquis
Copy link
Contributor Author

For anyone interested in updates, I've pushed a new PR that enables "almost" proper Android test fixtures thanks to AGP 8.5.0:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants