Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I print an information message in JUnit tests?

Tags:

android

junit

I am running JUnit tests as part of my Android app tests. In this case it's just testing the responses of an API we rely on that may be changed frequently (in order to validate later tests)

When these tests pass the output window of Android studio shows no messages. We'd instead like to start each method with a message saying which endpoint it is testing (E.g. "Tests /oranges//segments") so that the message always shows as the first message for both passing and failing tests.

I tried the android logs Log.println(Log.ASSERT, "...", "...") but that did not show in the android studio output.

Is there a way to do this? The output window I refer to is the one displayed below

enter image description here

(When a test is marked as ignored, you can supply a message to display. I'd just like the same behaviour for my other tests)

like image 618
Nick Cardoso Avatar asked Jun 29 '16 09:06

Nick Cardoso


1 Answers

The old fashioned Java styled System.out.println(); will work.

like image 111
R. Zagórski Avatar answered Oct 13 '22 02:10

R. Zagórski