Hey all, quick question as I can't find any solid ...
# announcements
m
Hey all, quick question as I can't find any solid resources for this. How does one test extension methods? Say I have something like
fun Date.isWeekend() = day == 6 || day == 7
Inside a class. How do I go about unit testing this?
a
Should be straightforward if you are writing Kotlin Test classes but if you are using Java you can add @JvmName("isWeekend") annotation to the method and then call it by passing the Date as the 1st parameter: e.g.
isWeekend( new Date())
(forgotten how much I hate writting
new
🙂 )
k
The JvmName is already
isWeekend
. You shouldn’t need an extra annotation