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

ref on an NSObject returns a private type #1863

Closed
stuartmorgan-g opened this issue Jan 3, 2025 · 0 comments · Fixed by #1897
Closed

ref on an NSObject returns a private type #1863

stuartmorgan-g opened this issue Jan 3, 2025 · 0 comments · Fixed by #1897

Comments

@stuartmorgan-g
Copy link

All NSObjects extend NSObject, which extends objc.ObjCObjectBase, which extends _ObjCRefHolder<c.ObjCObject, _ObjCObjectRef>, which declares a public ref getter:

class _ObjCRefHolder<T extends NativeType, Ref extends _ObjCReference<T>> {
  final Ref ref;

So every object has a ref property that returns a _ObjCObjectRef, which makes it annoying to mock with mockito (similar to also #1861):

Invalid @GenerateMocks annotation: Mockito cannot generate a valid mock class which implements 'NSBundle' for the following reasons:
    The property accessor '_ObjCRefHolder.ref' features a private return type, and cannot be stubbed. Try generating this mock with a MockSpec with 'unsupportedMembers' or a dummy generator (see https://pub.dev/documentation/mockito/latest/annotations/MockSpec-class.html).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants