Hi guys, can somebody tell me how do you unit test...
# android
n
Hi guys, can somebody tell me how do you unit test extension functions? Do you verify them as standard method calls or as static methods calls?
m
If you unit test a function, doesn't matter if it is extension, top-level or static in java, just call it and check result.
n
I agree, but can junit4 test static method? I need power mock for that, don't I ?
j
If it's just about testing the function itself, just call the function! Retrieve the result on a variable and assert to it. If you are trying to test a class which is using the extension function, just think that you call those functions over an object instance, not as static functions. So you shouldn't have any difference either on testing a class with standard function calls inside of it's methods.
👍 1