1. pom.xml

Junit API 다운

		<!-- spring-test 추가-->
		<!-- 버전은 사용하는 springframework 버전과 동일한 버전 -->
		<dependency>
		    <groupId>org.springframework</groupId>
		    <artifactId>spring-test</artifactId>
		    <version>${org.springframework-version}</version>
		    <scope>test</scope>
		</dependency>
		
		<!-- 버전 수정 -->
		<!-- 4.7 -> 4.12 이상 -->
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.12</version>
			<scope>test</scope>
		</dependency>        
	</dependencies>

2. Spring Legacy

- junit Test 도구는 Back-end(java)를 서버실행과 Client 요청 없이 실행

- Test Case 파일마다 선언부위에 다음을 작성
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations= {"file:src/main/webapp/WEB-INF/spring/**/*-context.xml"})
public class Test {...}

- Test 패키지 내부에 base package에 추상 클래스를 작성 하고 상속 받아서 사용

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations= {"file:src/main/webapp/WEB-INF/spring/**/*-context.xml"})
public abstract class Parent {}

public class Child extends Parent {}

1. src/test/java 내부에 비어있는 베이스 패키지 내에 Test case 생성

2. Junit Test Case 테스할 메서드 생성

3. Test 메서드로 등록 하기 위해 메서드 선언부 위에 @Test 선언 Test 내용작성

4. 테스트할 Test case 파일 우클릭 -> run as -> junit test case

3. Assert

- 단정문
- Test의 결과를 확인(성공, 실패, 에러)
- Assert 상세 내용
https://junit.org/junit5/docs/current/api/org.junit.jupiter.api/org/junit/jupiter/api/Assertions.html

4. Test Annotation

1. @BeforeAll( or BeforeClass ) : 테스트 클래스 시작시 딱 1번 호출, 전체 설정, 메서드는 클래스 메서드로 선언
		@BeforeAll( or BeforeClass )
		public static void beforeAllMethod(){}

2. @AfterAll(or AfterClass ) : 테스트 클래스 종료시 딱 1번 호출, 마무리 작업 메서드는 클래스 메서드로 선언
		@AfterAll( or BeforeClass )
		public static void AfterAllMethod(){}

3. @BeforeEach( or Before )  : 각각의 테스트 메서드 실행 전 한번씩 호출, 일반 멤버 메서드 선언
		@BeforeEach( or Before )
		public void beforeEachMethod(){}

4. @AfterEach( or After )  : 각각의 테스트 메서드 실행 후 한번씩 호출, 일반 멤버 메서드 선언
		@AfterEach( or After )
		public void afterEachMethod(){}

5. @Test    : Test를 수행할 메서드에 선언
		@Test
		public void testMethod(){}

-- Test Case 메서드 선언부에 Annotation을 주지 않으면 일반 멤버메서드라서, 자동으로 실행 X