Dropwizard support testing of Resources via ResourceTestRules.
If you’re using Dropwizard Validation and you want to test the 422 responses and error messages using ResourceTestRule, you might try something like …
But instead you might get a RuntimeException something like…
The trick is you, you need to wire up a provider to handle the Exception as per Dropwizard’s normal pipeline.
You can do that as follows, adding the ConstraintViolationExceptionMapper using “addProvider”:
Now, you should see your normal 422 responses and error messages come out when using ResourceTestRule!