New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gradle 4.6: junit5 integration ignores exceptionFormat #4681
Comments
Thanks for reporting, but I tried with the procedure you mentioned and did observe the stacktrace. Here's what I tried:
And my console displays:
It would be great if you can provide a minimum sample project. Thanks! |
Thank you very much for investigating! You're right - it works properly for
When I now run
The JUnit-based stacktraces are properly visible, yet the stacktraces reported by the custom testing tool are cut off. |
I'm sorry but I can't reproduce it with the procedure you described. I did as you said and only get:
Can you checkout a branch which has everything and doesn't need me to manually edit here and there? |
Thanks, sure! I have created the
|
Thanks, now I see this behavior. After a little investigation, I found the root cause. For the JUnit-based test, Gradle gets an exception like this:
It's too long so Gradle has to truncate it, but from where? Gradle knows the current test method is
However, for your custom engine, the exception looks like this:
It's too hard for Gradle to decide where to start truncating, so it has to truncate all. That's why you see
I think for a while and failed to think of a solution for this. For the latter case, what's your expected behavior? Where do you want it to be truncated? |
I understand that there is lot of thought put into Gradle's code and hence I'm hesitant to offer my advice on the matter. Yet, here I go :) I am using Travis-CI to test my projects. When a test fails, for me the quickest way to learn the cause of the failure is to see the stacktrace of the exception thrown. Typically one reads the Since I have specifically configured Gradle to show full exception format, showing a full untruncated stack trace is therefore expected and acceptable for me, because it enables me to find the source of the bug. Since there are at most a handful of tests failing in the most common case, full stack traces will not clutter up the console output badly. Of course, if Gradle is smart enough to chop out pieces of stack trace that are unimportant, that's even better. However, if it is not possible to do so, I find it perfectly acceptable for Gradle to fall back and show the full stack trace. Now for the truncating algorithm: I am hesitant to give advice since I haven't thought about the algorithm that much. I was thinking of the following algorithm:
The important thing is that the algorithm should fall back to show a full stack trace instead of an empty one. |
Thanks for your thought! I think that's pretty reasonable. However we might not have enough capacity to support this, would you like to provide a pull request? The related logic is in FullExceptionFormatter, ClassMethodNameStackTraceSpec and TruncatedStackTraceSpec. No pressure, it's totally up to you. |
P.S. in the case you provided, the test descriptor's class name ( So I guess it's not easy to "know the class being tested". |
This fixes #4681 Previously, when TestExceptionFormatter formats test stacktraces, it tries to find the exactly matched class/method name as stacktrace truncation point. However, some kotlin-based tests have only anonymous classes in their stacktraces, which makes it impossible to find the exact truncation point. This PR treats `SomeClass$1$1$1` and `SomeClass` equally when performing class name matching.
…4797) Make ClassMethodNameStackTraceSpec support anonymous class matching This fixes #4681 Previously, when TestExceptionFormatter formats test stacktraces, it tries to find the exactly matched class/method name as stacktrace truncation point. However, some kotlin-based tests have only anonymous classes in their stacktraces, which makes it impossible to find the exact truncation point. This PR treats `SomeClass$1$1$1` and `SomeClass` equally when performing class name matching.
Thank you very much, and I apologize I was unable to find time to fix this myself. |
Not at all! Thanks for the reporting! Please try our |
Just tested with Gradle 4.7-rc-1 and the bug is indeed fixed!
Awesome, thank you guys :) The stack trace is truncated exactly at |
Thanks @mvysny ! |
I have the following in my
build.gradle
file:Since I'm using Travis-CI, I do not have access to the text report html file. Therefore, I would like to see the stacktraces of failed tests in the console. However, Gradle seems to ignore the
exceptionFormat
parameter and does not print the stacktraces into the console:Expected Behavior
The full stacktraces of failed tests should be printed into the console.
Current Behavior
Only the exception type and the message is printed. That unfortunately doesn't give insight to the root of the issue.
Context
Since I'm using Travis-CI, I do not have access to the text report html file. Therefore, I would like to see the stacktraces of failed tests in the console.
Steps to Reproduce (for bugs)
Create a junit5-based project with one failing tests; then configure Gradle with:
Your Environment
java -version
openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-0ubuntu0.17.10.2-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)
The text was updated successfully, but these errors were encountered: