Closed workmichsem closed 4 months ago
I found the answer. The fact is that when using JUnit 4, console output is usually available in the Logs tab. This is very convenient since the logs relate to only one selected test. But when using JUnit 5 Android Studio stops displaying them there. but still displays in Logcat
Hey, thanks for reporting. The lack of easy access to per-test logs via the Test window in AS is something that has bugged me for a while as well. I haven't had the time to investigate how exactly it's able to pick up JUnit 4-based logs for this window, but it might be worth looking into the sources to figure out the integration here. My initial guess is that it is probably integrated via UTP, something that I remember looking into for a different issue a while back.
I'm renaming this ticket to track this as a feature request for the future. In the meantime, please refer to Logcat as a workaround!
Huh, actually, after testing it again just now, there is some test output in AS for the JUnit 5 test. I wonder if this is resolved in a recent AS version? For context, I'm using Jellyfish Canary 7 and the output for your example code has the expected logs in the corresponding window. Could you share your AS version for reference?
For a different angle, I am also noticing that while you are using the android-test libraries, there is no usage of the android-junit5 plugin. Instead, JUnit 5 is configured manually (e.g. via useJUnitPlatform
in your testOptions
). I don't recall anything specific to logs, but the plugin and instrumentation libraries do communicate with each other in several ways and the plugin configures the androidTest
libraries in a certain way. Hence, it's possible that some of the plugin's work is missing in your project and causing the logs to not show. 🤔
I'm running Android Studio Jellyfish | 2023.3.1
together with de.mannodermaus.android-junit5:1.10.0.0
and can confirm that the log output is visible per test in instrumentation tests!
I trying to use your library, and I can't see the test logs
There is my gradle:
There is my simple code:
The test passes, but all I see is "No logcat output for this device."