Top "Hamcrest" questions

Hamcrest is an open source library of constraint classes used to match objects and values, typically by other frameworks such as unit testing, mocking, or collections.

java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing

While running junit test in eclipse I am getting this Exception: java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing I've added junit.…

java eclipse junit noclassdeffounderror hamcrest
How do I assert an Iterable contains elements with a certain property?

Assume I want to unit test a method with this signature: List<MyItem> getMyItems(); Assume MyItem is a …

java unit-testing junit4 hamcrest
Hamcrest compare collections

I'm trying to compare 2 lists: assertThat(actual.getList(), is(Matchers.containsInAnyOrder(expectedList))); But idea java: no suitable method found for …

java junit hamcrest
Checking that a List is not empty in Hamcrest

I was wondering if anyone knew of a way to check if a List is empty using assertThat() and Matchers? …

java collections junit hamcrest
Getting "NoSuchMethodError: org.hamcrest.Matcher.describeMismatch" when running test in IntelliJ 10.5

I'm using JUnit-dep 4.10 and Hamcrest 1.3.RC2. I've created a custom matcher that looks like the following: public static class MyMatcher …

java junit intellij-idea junit4 hamcrest
How to test enum types?

I'm currently trying to build a more or less complete set of unit tests for a small library. Since we …

unit-testing enums hamcrest
How to assertThat something is null with Hamcrest?

How would I assertThat something is null? for example assertThat(attr.getValue(), is("")); But I get an error saying that …

java assert hamcrest
Why doesn't this code attempting to use Hamcrest's hasItems compile?

Why does this not compile, oh, what to do? import static org.junit.Assert.assertThat; import static org.junit.matchers.…

java unit-testing junit hamcrest matcher
How to use JUnit and Hamcrest together?

I can't understand how JUnit 4.8 should work with Hamcrest matchers. There are some matchers defined inside junit-4.8.jar in org.…

java junit hamcrest
How to check if collection contains items in given order using Hamcrest

How to check using Hamcrest if given collection is containing given items in given order? I tried hasItems but it …

java collections hamcrest