Created
May 14, 2019 17:29
-
-
Save ajurasz/2fe0e61ce3272a052bcdc4efd40acfd4 to your computer and use it in GitHub Desktop.
EveryItem hamcrest matcher usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static org.hamcrest.core.Every.everyItem; | |
import static org.hamcrest.core.Is.is; | |
import static org.hamcrest.core.IsNot.not; | |
import static org.junit.Assert.assertThat; | |
import java.util.Arrays; | |
import java.util.Collection; | |
import org.junit.Test; | |
public class EveryItemTest | |
{ | |
@Test | |
public void every_item_in_list_is() { | |
Collection<String> array = Arrays.asList("a", "a", "a"); | |
assertThat(array, everyItem(is("a"))); | |
} | |
@Test | |
public void not_every_item_in_list_is() { | |
Collection<String> array = Arrays.asList("a", "b", "a"); | |
assertThat(array, not(everyItem(is("a")))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment