I wanted to try the @VisibleForTesting annotation for a android unit-test - I have a class with one annotated method:
public class Foo {
public void bar() {
}
@VisibleForTesting
private void baz() {
}
}
but in the unit-tests I still can only see bar - not baz
The point of this annotation is that its convention and could be used in static code analysis.
Change the visibility of your method to package. In this case your method has reduced visibility for testing and is only visible to tests in the same package.
public class Foo {
public void bar() {
}
@VisibleForTesting
/* package */ void baz() {
}
}
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