How to use VisibleForTesting for pure JUnit tests
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:
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:
Ok, you’ve declared junit dependency for test classes only (those that are in src/test/java but you’re trying to use it in main classes (those that are in src/main/java). Either do not use it in main classes, or remove <scope>test</scope>.
Did you include the hamcrest-core-1.3.jar file in your classpath? If not included means include that jar and try once again.
@Dennis Roberts: You were absolutely right: My test class was located in src/main/java. Also the value of the “scope” element in the POM for JUnit was “test”, although that is how it is supposed to be. The problem was that I had been sloppy when creating the test class in Eclipse, resulting in it being … Read more