Guest User

Untitled

a guest
May 26th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. import static com.sample.springboot.BookStoreTestHelper.*;
  2. //生成メソッドはstaticインポートで利用した方が読みやすい
  3. import static org.hamcrest.CoreMatchers.*;
  4. import static org.junit.Assert.*;
  5.  
  6. import org.junit.Test;
  7.  
  8. public class BookStoreTest {
  9.  
  10. @Test
  11. public void testGetTotalPrice() throws Exception {
  12. // SetUp
  13. BookStore sut = new BookStore();
  14. Book book = CreateBookObject_Refactoring_by_MartinFowler();
  15. //インスタンスの生成が長くなるので別クラスの生成メソッドを呼んでいる
  16. sut.addToCart(book, 1);
  17. // Execise & Verify
  18. assertThat(sut.getTotalPrice(), is(4500));
  19. }
  20.  
  21. @Test
  22. public void testGet_0() throws Exception {
  23. // SetUp
  24. BookStore sut = new BookStore();
  25. Book book = CreateBookObject_Refactoring_by_MartinFowler();
  26. sut.addToCart(book, 1);
  27. // Execise & Verify
  28. assertThat(sut.get(0), is(sameInstance(book)));
  29. }
  30. }
Add Comment
Please, Sign In to add comment