JUnit 4.4 - Hamcrest Asserts - No Fluff Just Stuff

JUnit 4.4 - Hamcrest Asserts

Posted by: Srini Penchikala on May 13, 2008

I had to upgrade the JUnit version I have been using to version 4.4 in a recent project to get Spring/JUnit integration working with new testing features available in Spring 2.5 release (which make it easy to get a reference to any Spring bean w/o having to specifically load Spring application context). JUnit 4.4 also comes with Hamcrest testing framework which has several additional assert statements than what are there in plain JUnit.

I started using some of these new assert statements which are very BDD'ish in nature and make the test methods more readable on what we are asserting. We no longer have to struggle with the limited number of assert's that are available in JUnit.

Here is a good presentation that talks about the new features in JUnit 4.4 (additional assets, timeout, datapoints etc.)
Srini Penchikala

About Srini Penchikala

Srini Penchikala currently works as an Enterprise Architect at a major financial organization in Metropolitan Detroit area. He has over 14 years of IT experience and has been working on Java projects since 1996 and J2EE technology since 2000. His main areas of interest are Agile Enterprise and Service Oriented Architectures, Domain Driven Design & Development In Practice, Aspect-Oriented Programming (AOP), Architecture Rules Enforcement, Enterprise Integration Patterns, and light-weight middleware frameworks such as Spring and Hibernate. He has presented at conferences and Java User Groups on topics like Agile Enterprise Architectures, Architecture Governance, and Domain-Driven Design. He has published numerous articles on J2EE topics on websites like InfoQ.com, ServerSide.com, O'Reilly Java Network (ONJava), DevX Java, java.net and JavaWorld. Srini also publishes a blog on Java, JEE, and other topics at http://srinip2007.blogspot.com/. He is also a leader of Detroit Java User Group (http://sites.google.com/site/detroitjug/).

Why Attend the NFJS Tour?

  • » Cutting-Edge Technologies
  • » Agile Practices
  • » Peer Exchange

Current Topics:

  • Languages on the JVM: Scala, Groovy, Clojure
  • Enterprise Java
  • Core Java, Java 8
  • Agility
  • Testing: Geb, Spock, Easyb
  • REST
  • NoSQL: MongoDB, Cassandra
  • Hadoop
  • Spring 4
  • Cloud
  • Automation Tools: Gradle, Git, Jenkins, Sonar
  • HTML5, CSS3, AngularJS, jQuery, Usability
  • Mobile Apps - iPhone and Android
  • More...
Learn More »