Skip to content

Add test utility for error-specific RemoteException and SerializableError#2718

Merged
bulldozer-bot[bot] merged 1 commit intodevelopfrom
mpritham/exception-test-utility
Nov 21, 2025
Merged

Add test utility for error-specific RemoteException and SerializableError#2718
bulldozer-bot[bot] merged 1 commit intodevelopfrom
mpritham/exception-test-utility

Conversation

@mpritham
Copy link
Contributor

Before this PR

Previously devs would mock interactions with Dialogue clients that threw a RemoteException by creating a Mockito mock returning a constructed RemoteException. Now, clients throw subclasses of RemoteException. It is not possible to construct these error-specific RemoteExceptions because the error's SerializableError constructor (a required parameter when constructing the RemoteException subclass) 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-specific RemoteExceptions for use in unit tests.

After this PR

For each error, generate a test utility class that is able to construct error specific RemoteExceptions and SerializableErrors.

==COMMIT_MSG==
Add test utility for error-specific RemoteException and SerializableError
==COMMIT_MSG==

Possible downsides?

I would like folks to only use this in tests. I've named the class TestUtility and 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.

@changelog-app
Copy link

changelog-app bot commented Nov 13, 2025

Generate changelog in changelog/@unreleased

Type (Select exactly one)

  • Feature (Adding new functionality)
  • Improvement (Improving existing functionality)
  • Fix (Fixing an issue with existing functionality)
  • Break (Creating a new major version by breaking public APIs)
  • Deprecation (Removing functionality in a non-breaking way)
  • Migration (Automatically moving data/functionality to a new system)

Description

Add test utility for error-specific RemoteException and SerializableError

Check the box to generate changelog(s)

  • Generate changelog entry

@mpritham mpritham force-pushed the mpritham/exception-test-utility branch from 83bc13e to 029af93 Compare November 13, 2025 19:10
Copy link
Contributor

@aldexis aldexis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

aldexis
aldexis previously approved these changes Nov 14, 2025
@mpritham mpritham force-pushed the mpritham/exception-test-utility branch from 029af93 to 5f2df76 Compare November 21, 2025 14:12
@policy-bot policy-bot bot dismissed aldexis’s stale review November 21, 2025 14:12

Invalidated by push of 5f2df76

@changelog-app
Copy link

changelog-app bot commented Nov 21, 2025

Successfully generated changelog entry!

Need to regenerate?

Simply interact with the changelog bot comment again to regenerate these entries.


📋Changelog Preview

💡 Improvements

  • Add test utility for error-specific RemoteException and SerializableError (#2718)

@bulldozer-bot bulldozer-bot bot merged commit 83b579a into develop Nov 21, 2025
5 checks passed
@bulldozer-bot bulldozer-bot bot deleted the mpritham/exception-test-utility branch November 21, 2025 16:04
@autorelease3
Copy link

autorelease3 bot commented Nov 21, 2025

Released 8.64.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants