Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

285
Views
¿AndroidThreeTen no funciona en la prueba unitaria sin robolectric?

Tengo problemas para crear una prueba unitaria sin necesidad de robolectric. Estoy usando AndroidThreeTen.init(this) en mi código y cuando ejecuto mi prueba si deshabilito robolectric obtengo un error: org.threeten.bp.zone.ZoneRulesException: No time-zone data files registered

y si lo dejo habilitado obtengo esto: [Robolectric] com.mycomp.,yapp.utilities.log.LogTest.on Calling function w it returns an Int: sdk=28; resources=BINARY

Intenté usar testImplementation 'com.jakewharton.threetenabp:threetenabp:1.1.0' sin hacer ninguna diferencia. Tengo AndroidThreeTen.init(this) llamado en mi aplicación y testApplication. ¿algunas ideas? esta es mi prueba

 @Test fun `on Calling function i it returns an Int`() { assertThat("Returned class is not an Int", Log.i("Test", "Test"), isA(Int::class.java)) assertThat("Returned Int is not 0", Log.i("Test", "Test"), `is`(0)) }

¿O tengo que usar robolectric debido a esto? (Nota al margen: el registro no es el util.log de Android sino mi propia clase) (editado)

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Las pruebas unitarias de JVM no se ejecutan en el tiempo de ejecución de Android. En lugar de ThreeTenABP, puede usar ThreeTenBP directamente para obtener la misma API inicializada para una JVM normal.

En mi proyecto build.gradle utilizo una configuración como:

 implementation "com.jakewharton.threetenabp:threetenabp:${threetenabpVersion}" testImplementation("org.threeten:threetenbp:${threetenbpVersion}") { exclude module: "com.jakewharton.threetenabp:threetenabp:${threetenabpVersion}" }

donde

 threetenabpVersion = '1.2.0' threetenbpVersion = '1.3.8'

Esto usa ThreeTenBP a través de ThreeTenABP normalmente, pero en la configuración de prueba unitaria agrega TreeTenBP directamente como una dependencia, con su código de inicio. No puedo recordar exactamente por qué puse la regla de exclude ; ha sido así durante unos años ya.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!