Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import static com.sample.springboot.BookStoreTestHelper.*;
- //生成メソッドはstaticインポートで利用した方が読みやすい
- import static org.hamcrest.CoreMatchers.*;
- import static org.junit.Assert.*;
- import org.junit.Test;
- public class BookStoreTest {
- @Test
- public void testGetTotalPrice() throws Exception {
- // SetUp
- BookStore sut = new BookStore();
- Book book = CreateBookObject_Refactoring_by_MartinFowler();
- //インスタンスの生成が長くなるので別クラスの生成メソッドを呼んでいる
- sut.addToCart(book, 1);
- // Execise & Verify
- assertThat(sut.getTotalPrice(), is(4500));
- }
- @Test
- public void testGet_0() throws Exception {
- // SetUp
- BookStore sut = new BookStore();
- Book book = CreateBookObject_Refactoring_by_MartinFowler();
- sut.addToCart(book, 1);
- // Execise & Verify
- assertThat(sut.get(0), is(sameInstance(book)));
- }
- }
Add Comment
Please, Sign In to add comment