Last week I wrote about writing JUnit tests with accurate exception matching
. That relies on the Hamcrest
library to work. Unfortunately the JUnit Maven
artefact uses only the hamcrest-core
dependency which leads to some compilation errors like this...
The dependency tree
shows up like this...
As expected, but incomplete. After checking the Hamcrest Distributables
page it becomes clear that the hamcrest-core
is the bare minimum dependency and doesn't include the required matchers and supporting classes. What's required is the hamcrest-library
dependency. This is easily resolved, just add this to your pom.xml
The dependency tree now looks like this and all of the compilation errors are fixed!
Hope you found this post useful...
...so please read on! I love writing articles that provide beneficial information,
tips and examples to my readers. All information on my blog is provided free of
charge and I encourage you to share it as you wish. There is a small favour I ask in return however -
engage in comments below, provide feedback, and if you see mistakes let me know.
If you want to show additional support and help me pay for web hosting and
domain name registration,
donations, no matter how small, are always welcome!
Use of any information contained in this blog post/article is subject to this disclaimer
Other posts you may like...