Add test utility for error-specific RemoteException and SerializableError#2718
Conversation
Generate changelog in
|
83bc13e to
029af93
Compare
aldexis
left a comment
There was a problem hiding this comment.
If we want to make sure this doesn't get used outside of tests, we could go one step further, and create a separate xxx-test-utilities library, but this seems much more involved, so this feels reasonable to me
| * This utility class is provided to make creating error-specific exceptions easier for tests. It should not be used | ||
| * outside of tests! | ||
| */ | ||
| public static final class ComplicatedParametersTestUtility { |
There was a problem hiding this comment.
Another approach would be to have one TestUtility class per XErrors class. Makes the "Test" part of the name a bit more prominent.
I don't have strong feelings either way.
There was a problem hiding this comment.
Think I'll merge with the current state. With the approach where we have one test utility, I think we'd have to name each method like createXSerializableError. I think it'd be slightly easier to search for usages of places folks have created these errors by having all the constructors have the same name.
029af93 to
5f2df76
Compare
Invalidated by push of 5f2df76
✅ Successfully generated changelog entry!Need to regenerate?Simply interact with the changelog bot comment again to regenerate these entries. 📋Changelog Preview💡 Improvements
|
|
Released 8.64.0 |
Before this PR
Previously devs would mock interactions with Dialogue clients that threw a
RemoteExceptionby creating a Mockito mock returning a constructedRemoteException. Now, clients throw subclasses ofRemoteException. It is not possible to construct these error-specificRemoteExceptions because the error'sSerializableErrorconstructor (a required parameter when constructing theRemoteExceptionsubclass) is package private. I'd like this to remain package-private: devs should not be constructing these errors in their production code. Still, there should be an easy way for folks to construct these error-specificRemoteExceptions for use in unit tests.After this PR
For each error, generate a test utility class that is able to construct error specific
RemoteExceptions andSerializableErrors.==COMMIT_MSG==
Add test utility for error-specific
RemoteExceptionandSerializableError==COMMIT_MSG==
Possible downsides?
I would like folks to only use this in tests. I've named the class
TestUtilityand provided a JavaDoc telling folks to only use this in tests. Still, it's possible for folks to construct and throw these Conjure-generated exceptions in their code if they really wanted to.