How to use VisibleForTesting for pure JUnit tests

后端 未结 4 777
南旧
南旧 2021-02-01 03:27

I´m running pure JUnit4 java tests over my pure java files on my project but I can\'t find a way to use @VisibleForTesting clearly without making the thing manually public.

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-01 03:43

    According to the Android docs:

    You can optionally specify what the visibility should have been if not for testing; this allows tools to catch unintended access from within production code.

    Example:

    @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
    public Address getAddress()
    

提交回复
热议问题