¤È¤¢¤ë½¸ÃÄ¤Î¥×¥í¥°¥é¥à¥á¥â

Sample Code

package org.sample.junit;

import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;

import org.junit.Test;

public class SampleAssertionTest {

	@Test
	public void test1() {
		assertThat(1, is(1));

		assertThat("boolean check", true, is(true));

		assertThat(1, not(2));
		assertThat(1, is(not(2)));

		assertThat(null, nullValue());
		assertThat(null, is(nullValue()));

		assertThat(1, notNullValue());
		assertThat(1, is(notNullValue()));

		assertThat(new Integer(1), instanceOf(Integer.class));

		Integer v = new Integer(2);
		assertThat(v, sameInstance(v));
		assertThat(v, is(sameInstance(v)));
		
	}
}
¥¿¥°

¥³¥á¥ó¥È¤ò¤«¤¯


¡Öhttp://¡×¤ò´Þ¤àÅê¹Æ¤Ï¶Ø»ß¤µ¤ì¤Æ¤¤¤Þ¤¹¡£

ÍøÍѵ¬Ìó¤ò¤´³Îǧ¤Î¤¦¤¨¤´µ­Æþ²¼¤µ¤¤

¥á¥ó¥Ð¡¼¤Î¤ßÊÔ½¸¤Ç¤­¤Þ¤¹