Still debugging locally, but since my local gradle build picked up 4. ComparisonFailure: expected: null but was: null at org. This is on comparison of two obviously non-null strings, for example assertEquals "a", "b".
This appears to be affecting our whole local team, but still may be something odd about our setup. Continuing to investigate. The text was updated successfully, but these errors were encountered:. Sorry, something went wrong.
Works for me as well. Here is the trace I get - org. We have been seeing this error on our CI box ubuntu , but not on our dev workstations Mac. In this case, the test is using assertj's assertThat long. The 4. That's on OS X, command may be somewhat different on different platforms , then the output shows the problem.
Oh, I guess Gradle is in the tar file as well. Never mind then. I've sent you an authorization request for the tar file via Google Drive. I can reproduce the problem. I tried remote debugging via. However, I did see that we correctly build the error message -- which does not make sense. If so, we should try to get help from someone that knows how Gradle's test runner works internally since I'm not a Gradle user.
So, at debug time I see the correct error message see System. However, when Gradle reports the exception, the field values expected and actual seem to have gone and are null then??? I wonder if this has something to do with is changing the field names in ComparisonFailure. Do you see the same problem if you compare two integers? Or is it unique to failures that use ComparisonFailure?
RuntimeException: wrapper at EqualityTest. However, when Gradle reports the exception, the field values expected and actual seem to have gone and are null. That's exactly right. Fixing this issue in ComparisonFailure is dead simple, other serializable classes where fields names were changed need to be updated in a similar manner. Apparently it does. I'm neither a Gradle developer nor user, so I don't actually know the internals of Gradle.
Updating the serial UID did resolve this problem, though. Later: I've just added a writeObject method to ComparisonFailure to check if and from where Gradle uses serialization. Here's the call stack:. The key to understanding this issue indeed seems to be Gradle's Message class.
Apparently, Gradle uses it for communication between its test runner and the system under test. In the above stacktrace the ExceptionPlaceholder constructor serializes the exception and sends it to the test runner.
The test runner then calls read where a number of things are tried to restore the exception. As a first step seems it tries to deserialize the exception. If that does not succeed it will create a PlaceholderException with the same message, cause, stacktrace and so on.
Gradle uses two separate classpathes for the test runner and the system under test. The first is called "implementation classpath", the latter "application classpath". When you enable the debug output you'll get a trace of the two. I spare you the detailed output, essentially junit Thus, deserializing succeeds. However, the fields have been renamed, thus fExpected and fActual are both null.
Gradle will then create a PlaceholderException with the original message and stacktrace. Summing up, I think we need to go through all our classes that are Serializable and check whether we have renamed any fields since 4. I think we should undo the field renames for fields that are Serializable.
Changing the serialization format between minor releases is probably not a good idea. Viewed 12k times. Improve this question. Aneesh Aneesh 29 1 1 gold badge 1 1 silver badge 7 7 bronze badges. Use the debugger to ensure that both Strings are non-null.
Or print out the values before you test them. Is it possible that you are using unicode characters like in here? Thanks for the suggestion. Add a comment. Active Oldest Votes. Here's the Junit 4. Improve this answer. Stephen C Stephen C k 90 90 gold badges silver badges bronze badges. Another way of evaluating it is using assertTrue: assertTrue s1.
Juned Ahsan Juned Ahsan It is actually recommended to use assertEquals instead of assertTrue to check the equality of two objects as the message when the assertion fails is more easier to interpret. This statement is questionable too: "assertEquals checks the equality of the objects. It is not a good idea to compare string with equality". In fact, assertEquals uses Object. And if you are actually talking about the correct way to use assertTrue : 1 that is not obvious, 2 assertTrue is a red herring, 'cos he's not using it, and 3 that's a bad idea anyway; see Pangea's comment.
Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Stack Gives Back Safety in numbers: crowdsourcing data on nefarious IP addresses.
0コメント