After a year, I also clicked on a library to help test private methods and fields. I believe that on Android you still need to test private methods.
You want your activity methods to be closed so that other classes do not think that they can access it (the fragment may, but this is not good practice for me, it is better to use the pattern of the observed observer). Then you will get private fields and methods that you will only need to access using tests.
BoundBox does just that! The following is an example of a test that accesses 2 private fields for verification:
@UiThreadTest public void testCompute() { // given boundBoxOfMainActivity = new BoundBoxOfMainActivity(getActivity()); // when boundBoxOfMainActivity.boundBox_getButtonMain().performClick(); // then assertEquals("42", boundBoxOfMainActivity.boundBox_getTextViewMain().getText()); }
source share