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

Improve JVM testing for date/time format args #230

Open
drewhamilton opened this issue Sep 26, 2023 · 0 comments · May be fixed by #258 or #390
Open

Improve JVM testing for date/time format args #230

drewhamilton opened this issue Sep 26, 2023 · 0 comments · May be fixed by #258 or #390

Comments

@drewhamilton
Copy link
Collaborator

Much of what Paraphrase generates is testable on the JVM: androidx.collection.ArrayMap has a default implementation that is available on the JVM; generated code populates this map and returns. Most Android-specific code is part of the runtime, which can be replaced with fakes for JVM tests.

But for date/time arguments, Paraphrase generates code that uses classes from the android.icu.util package: Calendar, TimeZone, and ULocale. These classes have no default implementations, and thus fail on the JVM unless something like Robolectric is used. Further, even if Robolectric is used, these classes clash with JVM-friendly fake runtimes that use com.ibm.icu.text.MessageFormat, since the ICU package is different.

Possible fixes for this:

  1. Write all Android-specific code in the runtime. In the case of date/time args, this would imply creating some interface for generated code to interact with, which could be (statically? 😬) replaced with a fake.
  2. Dynamically resolve either android.icu or com.ibm.icu package in generated code based on some signal, like the presence of JUnit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant