Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which Hamcrest matcher to import

I am using Hamcrest in a gradle/JVM project via the org.hamcrest:hamcrest:2.2 artifact which is what the Hamcrest website recommends. When I go to static import a matcher, e.g. is or notNullValue, I am presented with 3 options of where to import it from. In the case of notNullValue these are:

  • org.hamcrest.CoreMatchers
  • org.hamcrest.Matchers
  • org.hamcrest.core.IsNull

I was wondering if there was a 'best practice' one to choose?

choice of imports

like image 945
hughjdavey Avatar asked Oct 29 '25 05:10

hughjdavey


1 Answers

You can import all of these functions like this:

import static org.hamcrest.Matchers.*;
like image 120
gurkan Avatar answered Oct 30 '25 21:10

gurkan