-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
NotSerializableException with AssumptionViolatedException #1192
Comments
While I agree this is awkward, I'd be interested in why you are trying to serialize the exception. |
I suspect an IDE or build tool is serializing the exception as part of its reporting mechanism. Unfortunately, I think any fix would break serialization compatibility even for cases where a matcher isn't passed in. We could fix it in JUnit5, and accept that some tools will be broken until they update their dependencies... Edit: actually, making the |
Yes the test results are collected and saved for reporting purposes. A report mail is generated from the saved results. I could change the code that serializes the results to not serializing the exception but serializing only the exception message since I only need this message later on. I don't know why the exception saves the matcher to generate the message every time it is needed. Maybe this behaviour is needed. But if not, wouldn't it be possible to generate the message in the constructor and throw away the matcher? |
@phoenix384 saving the message in the constructor would be possible, but if we did that IDEs and build tools compiled with older versions of JUnit wouldn't work with newer versions of JUnit. If marking the field as |
For example try to serialize the Exception thrown by
assumeNotNull(null, null);
Causes:
java.io.NotSerializableException: org.hamcrest.core.Every
org.junit.internal.AssumptionViolatedException is serializable because RuntimeException is. But the Matcher field is not serializable.
The text was updated successfully, but these errors were encountered: