uniffi-rs icon indicating copy to clipboard operation
uniffi-rs copied to clipboard

Add support for test only functions

Open tarikeshaq opened this issue 5 years ago • 2 comments

It's not urgent at all, since the consumer can create abstractions that hide certain functions but wanted to see what we think about this (Or if we just wanna say "leave it to the consumer to deal with it")

The idea is that there may be some functions that you want to expose for tests, but nothing else.

In Android you can do something like @VisibleForTesting(otherwise = VisibleForTesting.NONE)

I'm tempted towards the "leave it to the consumer to deal with" for the foreseeable future. But if we were to do this at some point, we can probably mark it with a WebIDL attribute similar to how errors are done in #31

┆Issue is synchronized with this Jira Task ┆Issue Number: UNIFFI-6

tarikeshaq avatar Jul 30 '20 22:07 tarikeshaq

This would be nifty to have!

Swift handles this a little differently—when you use @testable import to import a library, you get access to any internal (though not private or fileprivate) members and methods. For the Swift bindings, we could use the WebIDL attribute to keep the method internal instead of public.

linabutler avatar Jul 31 '20 00:07 linabutler

For android, this is implemented as androidx.annotation.VisibleForTesting, but the annotation processor is part of androidx, rather than kotlin itself. This will unlikely to be a problem for uniffi's consumers, but will make it hard for us to use outside of an android build process.

jhugman avatar Aug 03 '20 16:08 jhugman