
You will need to download and install Hamcrest for Java:
https://github.com/hamcrest/JavaHamcrest
After watching this video, students will understand the advantages of using Hamcrest, and the requirements for the course.
Explore Hamcrest's assertThat and equalTo methods to express assertions, verify a string length equals three, and use an optional custom error message with imports.
Explore Hamcrest string assertions by using starts with, ends with, contains, and equals, plus ignore case, empty and blank checks, to validate strings in unit tests.
Explore Hamcrest number methods for numeric assertions, using integers with less than, less than or equal to, equal to, greater than or equal to, and greater than, and floating-point checks within plus or minus delta.
Explore Hamcrest expression methods that boost JUnit readability by crafting expressive asserts with string comparisons and test annotations, and practice writing your own readable asserts.
Practice writing Hamcrest matchers to verify ride eligibility using a Person class with age and height, creating tests for eligible and not eligible, based on 10 and 48 inches.
Practice writing compressed matches with Hamcrest by testing thermometer readings against known values within 0.2 degrees Celsius using the closeTo matcher, iterating over arrays, and asserting each result.
Explore hamcrest's array methods in JUnit tests by using empty array, has size, and contains variants, including order-sensitive and order-insensitive assertions, with string, integer, and custom object arrays.
Learn Hamcrest collection methods for lists, sets, and maps to assert emptiness, size, containment, order, and exact key-value entries.
Explore Hamcrest object and null value matchers, including instance of and anything, with strings, lists, maps, and class hierarchies, and learn to assert null, not null, and class membership.
Learn to build a parameterized Hamcrest custom matcher by extending TypeSafeMatcher, implementing matchesSafely and describedTo, to verify the left value equals the sum of three constructor inputs.
Learn to implement a custom Hamcrest starts with matcher for strings, using a type safe matcher, and validate case sensitivity with practical tests like Apple and banana.
Write and test a custom Hamcrest matcher named alphanumeric to recognize non-empty strings that contain only digits or English letters, using a type safe matcher and a JUnit test runner.
Explore Hamcrest methods for Java beans, using hasProperty, equalTo, samePropertyValuesAs, and not to verify bean fields such as name and number in a football player example.
Conclude your Hamcrest quick start by understanding how Hamcrest works, using its methods, and writing custom matches, then apply these skills to your own projects.
JUnit is one of Java's most popular unit testing frameworks. Hamcrest is an additional layer that sits on top of JUnit, and it allows you to write expressive and developer-friendly unit tests. In this course, you will learn which imports to use, how to write and run Hamcrest tests, how to use Hamcrest's fundamental methods, and how to write your own custom Hamcrest matchers. No prior knowledge of Hamcrest is necessary. The course is example-driven instruction and includes guided practice and quizzes to strengthen your understanding. Basic knowledge of Java programming and JUnit is required.