Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mockito cannot mock function with UShort arguments #492

Open
pasta18 opened this issue Sep 13, 2023 · 3 comments
Open

Mockito cannot mock function with UShort arguments #492

pasta18 opened this issue Sep 13, 2023 · 3 comments

Comments

@pasta18
Copy link

pasta18 commented Sep 13, 2023

I want to mock this function:

class MyClass() {
  fun myFunction(argument: UShort): ByteArray {
    ....
  }
}
var mocked: MyClass = mock(MyClass::class.java)
doReturn(byteArrayOf()).`when`(mocked).myFunction(any())

When run test, this error occurred.

Cannot invoke "kotlin.UShort.unbox-impl()"
java.lang.NullPointerException: Cannot invoke "kotlin.UShort.unbox-impl()"
@renannprado
Copy link

@pasta18 did you find a workaround?

@pasta18
Copy link
Author

pasta18 commented Nov 2, 2023

@renannprado
No, no workaround has been found yet.

I didn't mock it, because there was no way to mock the target method.

@renannprado
Copy link

@pasta18 this may help in your case: #445 (comment)

In my case unfortunately it didn't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants