Can I print an information message in JUnit tests?
JUnit tests are not executed on a Android device (or emulator) but on Java Virtual Machine on PC's environment. You have two solution:
- Just use some Logger (like log4j, JDK logger, etc) or simply use System.out.
- Use Roboletric and its capability to define shadow classes to redefine Log class.
I suggest you the second way. Roboletric already have a shadow class for log. To redirect output into console
@Before
public void setUp() throws Exception {
ShadowLog.stream = System.out;
//you other setup here
}
Some references:
https://guides.codepath.com/android/Unit-Testing-with-Robolectric https://github.com/robolectric/robolectric-samples http://www.vogella.com/tutorials/Robolectric/article.html
I hope it helps.
The old fashioned Java
styled System.out.println();
will work.