Created
September 12, 2023 17:19
-
-
Save cmathew/dcc2a2681ca59dcfc941f609c1331351 to your computer and use it in GitHub Desktop.
Example of providing a stubbed dependency to an Android Lint unit test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Define Joda-Time stub | |
val JODA_STUB = TestFiles.kotlin( | |
""" | |
package org.joda.time | |
class DateTime( | |
private val moment: Int, | |
private val zone: String | |
) { | |
companion object { | |
fun now(): DateTime { | |
return DateTime(1000, "America/Los_Angeles") | |
} | |
} | |
fun toLocalDate(): LocalDate { | |
return LocalDate(2020, 11, 23) | |
} | |
fun toLocalDateTime(): LocalDateTime { | |
return LocalDate(2020, 11, 23) | |
} | |
} | |
data class LocalDate( | |
private val year: Int, | |
private val month: Int, | |
private val day: Int | |
) | |
data class LocalDateTime( | |
private val moment: Int | |
) | |
""", | |
).indented() | |
// Use Joda-Time stub | |
lint().files(JODA_STUB, ...)... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment