- 라이브러리추가(pom.xml) -spring-test -lombok -log4j - 라이브러리 버전 변경(pom.xml) -Junit 4.7 => 4.12 - 의존성 주입 테스트 - com.vam.sample 패키지 생성 - Chef.java / Restaurant.java 생성 - 테스트 위한 클래스 생성 - SampleTests.java 생성
33 lines
744 B
Java
33 lines
744 B
Java
package com.vam.sample;
|
|
|
|
import static org.junit.Assert.assertNotNull;
|
|
|
|
import org.junit.Test;
|
|
import org.junit.runner.RunWith;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.test.context.ContextConfiguration;
|
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
|
|
import lombok.extern.log4j.Log4j;
|
|
|
|
@RunWith(SpringJUnit4ClassRunner.class)
|
|
@ContextConfiguration("file:src/main/webapp/WEB-INF/spring/root-context.xml")
|
|
@Log4j
|
|
public class SampleTests {
|
|
|
|
@Autowired
|
|
private Restaurant restaurant;
|
|
|
|
@Test
|
|
public void textExit() {
|
|
|
|
assertNotNull(restaurant);
|
|
|
|
log.info(restaurant);;
|
|
log.info("-------------------------------");
|
|
log.info(restaurant.getChef());
|
|
|
|
}
|
|
|
|
}
|