spring junit test tip

52 views
Skip to first unread message

노력

unread,
Jan 26, 2011, 7:25:39 PM1/26/11
to Korea Spring User Group
이게 tip 이 될지 잘 모르겟네요. 이미 아시는 분들두 있겠구요.

토스강남 읽기 모임에서 P.205 리스트 2-27 에서

@ContextConfiguration junit.xml 파일을 정의 안해서 FileNotFoundException 발생하
는 언급이 있었습니다.

재미있는건 Junit view -> Failure Trace 내용을 보면,

Caused by: java.io.FileNotFoundException: class path resource [test/
JunitTest-context.xml] cannot be opened because it does not exist

요렇게 찍히더라구요.

그럼 결국 동레벨 패키지에 junit.xml 파일을 위치해 두고,

파일명을 JunitTest-context.xml 로 바꾸어서 xml 경로 지정 없이 사용하면 되는 결론입니다.

이상입니다. ㅋ

노력

unread,
Jan 26, 2011, 8:27:22 PM1/26/11
to Korea Spring User Group
"Unit Test 클래스명" + -context.xml 로 하면 됩니다.

요거 web.xml 에 정의 하는거랑 비슷한거 같습니다.

-servlet.xml 하는거처럼... 뭐 구지 이렇게 안해도 되지만요.

warnee

unread,
Jan 26, 2011, 9:08:14 PM1/26/11
to Korea Spring User Group
그렇군요~~ ^^

파일 이름 바꾸기 귀찮으신 분들은

@ContextConfiguration 의 뒤에 ("junit.xml")이라고 xml을 직접 선언해 주어도 괜찮습니다~

노력

unread,
Jan 27, 2011, 7:22:01 AM1/27/11
to Korea Spring User Group

Sungchul Park

unread,
Jan 27, 2011, 8:05:45 AM1/27/11
to ks...@googlegroups.com
이번 모임 때 황지환님이 질문하셨던 내용이 잘 정리되어 있네요.
초반에 친절하게 설명하다 마무리를 얼버무려서 좀 아쉽지만요. ㅎㅎ
고맙습니다.

> JUnit& Spring - What You Don't Know
>
> http://java.dzone.com/articles/junit-spring-%E2%80%93-what-you-don%E2%80%99t
>
> 괜찮네요
>

Reply all
Reply to author
Forward
0 new messages