For Android App, I tried to use @VisibleForTesting()
as per https://developer.android.com/reference/android/support/annotation/VisibleForTesting
@VisibleForTesting()
void myFunction(String id) {
doSomething(id);
}
Tried it both for Java and Kotlin code.
I explicitly having the production call the public function that is annotated with @VisibleForTesting()
. When I compile, I don't see any error or warning thrown to prevent me from using it in Production code.
Did I miss anything?
This will be asserted by Android's Lint, and defaults to a warning.
You may change that by increasing the severity level to error in your build.gradle
:
android {
lintOptions {
error("VisibleForTests")
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With