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.

Why should I use Hamcrest-Matcher and assertThat() instead of traditional assertXXX()-Methods

When I look at the examples in the Assert class JavaDoc assertThat("Help! Integers don't work", 0, is(1)); // fails: // failure message: // …

java testing junit junit4 hamcrest
How to assertThat String is not empty

Asserting that a string is not empty in junit can be done in the following ways: assertTrue(!string.isEmpty()); assertFalse(…

java unit-testing junit hamcrest
How do Hamcrest's hasItems, contains and containsInAnyOrder differ?

Hamcrest provides a number of matchers for asserting the contents of a collection. All of these cases pass: Collection<…

hamcrest
Mockito and Hamcrest: how to verify invocation of Collection argument?

I'm running into a generics problem with Mockito and Hamcrest. Please assume the following interface: public interface Service { void perform(…

java generics mockito hamcrest
Composer hanging while updating dependencies

I tried updating a Laravel project I'm working on today using composer update But it hung on Updating dependencies (including …

json composer-php hamcrest
assert collection does not contain item

Using the hamcrest library for Java, what's a nicely readable way to do the opposite of: assertThat(someCollection, hasItem(someItem)) …

java hamcrest
Ant + JUnit: NoClassDefFoundError

Ok, I'm frustrated! I've hunted around for a good number of hours and am still stumped. Environment: WinXP, Eclipse Galileo 3.5 (…

java ant junit classpath hamcrest
hamcrest tests always fail

I am using hamcrest 1.3 to test my code. It is simply a die. I am trying to test it to …

java junit hamcrest
Map equality using Hamcrest

I'd like to use hamcrest to assert that two maps are equal, i.e. they have the same set of …

java collections hamcrest
mockito better expected exception test using spy

How can I make the 3rd test to check for the existence of cause1 in the message of the exception? …

java mockito junit4 hamcrest spy