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.

How to check for size AND presence of some items in collections in hamcrest

I'm using Hamcrest 1.3 and trying to achieve the following in a more compact way. Consider following test case: @Test public …

java junit hamcrest
How to verify that array contains object with rest assured?

For example, I have JSON in response: [{"id":1,"name":"text"},{"id":2,"name":"text"}]} I want to verify if a response …

java arrays rest-assured hamcrest
Spring MockMvc: match a collection of JSON objects in any order

I have an API endpoint which, when called with GET, returns an array of JSON objects in the body, like …

java spring spring-mvc hamcrest mockmvc
Is org.junit.Assert.assertThat better than org.hamcrest.MatcherAssert.assertThat?

I'm new to JUnit and Hamcrest and would like best-practice advice so I can decided which documentation to study first. …

java junit hamcrest
Want a JUnitMatchers AssertThat to test string contains 3 or more sub strings (currently using assertThat ... both ... and ....)

import static org.junit.matchers.JUnitMatchers.both; import static org.junit.matchers.JUnitMatchers.containsString; Now I check it contains foo …

java junit hamcrest
Hamcrest When to use Is or equalTo

I'm new using hamcrest. While I'm discovering how to use it I have been a doubt about when to use …

java hamcrest
Using hamcrest to match Map contains entries of different types

Let's say I have a Map: Map<String,Object> map1 = new HashMap<String,Object>(); map1.put("…

java unit-testing junit hamcrest
What is the idiomatic Hamcrest pattern to assert that each element of an iterable matches a given matcher?

Examine the following snippet: assertThat( Arrays.asList("1x", "2x", "3x", "4z"), not(hasItem(not(endsWith("x")))) ); This asserts that the …

java idioms hamcrest
Hamcrest - what version to use? 1.3 or 2

I am quite confused. Currently I am testing my spring application using <dependency> <groupId>org.springframework.…

java junit hamcrest
Mockito, JUnit, Hamcrest, Versioning

By default, the required version of Hamcrest for: JUnit 4.11 Hamcrest 1.3 Mockito-core 1.9.5 Hamcrest 1.1 There were not insiginifcant API changes between Hamcrest 1.1 …

java junit dependencies mockito hamcrest