JUnit/JUnit41 Test시, Mock(가짜) 객체 생성하여 주입해주기. @RunWith(SpringRunner.class) public class BookServiceTest { /* BookService 객체는 BookRepository 객체를 생성자에서 의존성 주입받아 사용하므로, BookRepositry가 구현되어있지 않으면, BookService객체에 대한 단위 테스트를 할 수 없다. 따라서, BookRepositry의 Mock(가짜)객체를 만들어, 해당 가짜 객체의 작동을 미리 정의해 준다. 그러면, BookService에서 이 가짜객체를 주입받아 테스트를 할 수 있다. */ @Mock BookRepository bookRepository; @Test public void save(){ // 새로운 Book 객체를 만든다. Book book = new Book();.. 2020. 3. 29. 이전 1 다음