|
Another weird thing, I added this below that TextKotlin code:
|
# ¿ Nov 9, 2022 16:37 |
|
|
# ¿ May 14, 2024 19:54 |
|
Anyone used mockk to mock extension functions on a singleton object before? I cant figure out any combination of mockkStatic or mockkObject that works. The specific thing I need to mock is google's firebase initialization, they've got it declared likeKotlin code:
I don't know why google made those extension functions in the same file instead of just being part of the object either, real pain in the rear end. FirebaseApp is in java instead of kotlin
|
# ¿ Feb 14, 2023 00:56 |
|
Forgot they have the source on github, this is the specific function I was trying to mock for tests https://github.com/firebase/firebas...Firebase.kt#L48
|
# ¿ Feb 14, 2023 01:02 |
|
I'm trying to mock the initialize function, not a context param
|
# ¿ Feb 14, 2023 04:30 |
|
You really aren't getting it
|
# ¿ Feb 14, 2023 04:52 |
|
Trying to setup unit tests for this analytics implementation we have that relies on firebase. For whatever reason google wrote the functions on the firebase object as extension functions which is making it difficult or impossible to mock those functions. I'll probably end up wrapping all the calls with another object that just directly forwards them without any additional logic to minimize the amount of untested code.
|
# ¿ Feb 14, 2023 05:31 |
|
Extension functions are pretty awkward in general for testing, since they don't actually "belong" to the object. Like if I had some type named Thing and in a file named Extensions.kt I wroteKotlin code:
Java code:
|
# ¿ Feb 14, 2023 05:49 |
|
|
# ¿ May 14, 2024 19:54 |
|
Yeah you can just unzip an apk, though it sounds like this is a game so the game data might be in some framework-specific format instead of PNGs
|
# ¿ Apr 7, 2023 23:13 |