Dropwizard supports integrated testing of via DropwizardAppRule.
When you spin up the app, you might want to use your default config.yml file and just override some of the values, specific for your test scenario.
You can use DropwizardAppRule and io.dropwizard.testing.junit.ConfigOverride to achieve this.
Say you have a config yml like:
You can overide some of the configs like following, where I use a base config.yml file, then override a port and set another config value:
You’ll note that some config nodes are collections (like server.applicationConnectors above), and you have to index reference them…
I didn’t find a good way to figure this out, other than using my debugger and seeing what was and wasn’t a collection as the DropwizardAppRule started up. There’s probably a sensible reason here for what is or isn’t a collection, but I didn’t think that hard about it :)
Anyways, I couldn’t find much info online about using ConfigOverides, so after a bit of source code digging this was what I came up with, hope it helps!