Nick Cardoso Nick Cardoso - 1 year ago 145
Android Question

Can I print an information message in JUnit tests?

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)

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download