Skip to content

Instantly share code, notes, and snippets.

@lfryc
Created August 14, 2013 16:32
Show Gist options
  • Save lfryc/6232827 to your computer and use it in GitHub Desktop.
Save lfryc/6232827 to your computer and use it in GitHub Desktop.
package org.richfaces;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;
public class MyTest {
private List<String> myList = Arrays.asList("a", "b", "c");
/**
* java.lang.AssertionError
*/
@Test
public void noMessage() {
assertTrue(myList.isEmpty());
}
/**
* java.lang.AssertionError: list is empty
*/
@Test
public void userProvidedMessage() {
assertTrue("list is empty", myList.isEmpty());
}
/**
* java.lang.AssertionError:
* Expected: is an empty collection
* but: <[a, b, c]>
*/
@Test
public void derivedMessage() {
assertThat(myList, is(empty()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment