JUnit Test Case ์์ฑ์ ์ ์ํ ์ : fail()
@Test
void testGetBoardPost() {
BoardService boardService = new MariaBoardService();
long id = 24;
BoardPost boardPost = boardService.getBoardPost(id);
System.out.println(">> boardPost=" + boardPost);
fail("Not yet implemented");
}
JUnit์ ๊น์์ ํ ์คํธ๋ฅผ ํด๋ดค๋๋ฐ ๊ณ์ fail์ด ๋ด๋ค.
๊ทธ๋์ ๋ก์ง์ด ์๋ชป๋ ์ค ์๊ณ ๋ช ๋ถ ๋์ ๋ก์ง์ ๊ณ ์น๊ณ ์์๋ค.
fail ๋ถ๋ถ์ ์ง์์ฃผ์ง ์๋๋ค๋ฉด ๊ณ์ ์คํจ๊ฐ ๋ฌ๋ค.
(์ฌ์ฉ๋ฒ์ ์์ง ์ ํ ๋ด ์๋ชป ๊ป๊ป)
์๋๋ฉด fail ๋ฉ์๋๋ฅผ ํธ์ถํ๋ ๊ฑด ์๋์ ์ผ๋ก ์คํจํ๋๋ก ํ์๋๋๊ฑฐ๊ธฐ ๋๋ฌธ์ด๋ค.
fail ๋ฉ์๋๋
fail ๋ฉ์๋๋ ํ ์คํธ ๋ฉ์๋ ๋ด์ ์์ผ๋ฉด ํด๋น ํ ์คํธ ๋ฉ์๋๋ฅผ ์ฆ์ ์คํจ์ํค๊ณ ๋๋จธ์ง ํ ์คํธ ์ฝ๋๋ฅผ ์คํํ์ง ์๋๋ก ํ๋ ์ญํ ์ ํ๋ค.
ํ์ง๋ง fail("Not yet implemented");์ ์ค์ ํ ์คํธ ์ฝ๋๋ฅผ ๋์ฒดํ๋ ๊ฒ์ด ์๋๋ผ ํ ์คํธ๊ฐ ์์ง ๊ตฌํ๋์ง ์์์์ ์๋ฆฌ๋ ์ฉ๋๋ก๋ง ์ฌ์ฉํด์ผ ํ๋ค.
ํ ์คํธ ์ฝ๋๋ฅผ ์์ฑํ๊ณ ํ ์คํธ๊ฐ ์์๋๋ก ์๋ํ๋๋ก ๊ตฌํํ ํ fail ๋ฌธ์ ์ ๊ฑฐํ๊ณ ํ ์คํธ๋ฅผ ์คํํด์ผ ํ๋ค.
โ์ fail ๋ฉ์๋๋ฅผ ์ฐ๋๊ฑด๊ฐ โ
์ฃผ๋ก ํน์ ํ ์คํธ ์ผ์ด์ค๋ ํน์ ๋ถ๋ถ์ด ์์ง ๊ตฌํ๋์ง ์์์ ๋ ๊ทธ๊ฒ์ด ์ด๋ค ๊ฒ์ด๋ผ๊ณ ๋ฉ๋ชจ๋ฅผ ๋จ๊ธฐ๊ธฐ ์ํด ์ฌ์ฉ๋๋ค.
๊ทธ๋์ ํ ์คํธ ํจ์๋ฅผ ์์ฑํด์คฌ๋ค๋ฉด fail ๋ฉ์๋๋ฅผ ์ญ์ ํด์ผ ํ๋ค.
@Test
void testGetBoardPost() {
BoardService boardService = new MariaBoardService();
long id = 24;
BoardPost boardPost = boardService.getBoardPost(id);
System.out.println(">> boardPost=" + boardPost);
// fail("Not yet implemented");
}
์ญ์ ํ๊ณ ๋ค์ ํ ์คํธ๋ฅผ ํ๋๋ ์ฑ๊ณต์ด๋ผ๊ณ ๋ด๋ค.
์น ๊ฐ๋ฐ์๋ ํ ์คํธ๋ฅผ ์น ๋ธ๋ผ์ฐ์ ์์ ํ์ธํ๋ฉด์ ํ๋ฉด ์ ๋๊ณ , ๋ฒ๊ฒ๊ณ ๊ท์ฐฎ๋๋ผ๋ test case๋ฅผ ํตํด์ ๊ฐ๋ฐ์ ํด์ผ ํ๋ค.
์ฒ์์๋ ์๊ฐ์ด ๋ง์ด ๊ฑธ๋ฆฐ๋ค๊ณ ์๊ฐ์ด ๋ค ์๋ ์์ง๋ง, ๋์ค์ ์๊ฐํ๋ค๋ฉด ๋ ์๊ฐ์ด ๋จ์ถ๋๊ธฐ ๋๋ฌธ์ test case๋ฅผ ์์ฑํ๋ ๊ฒ์ด ์ข๋ค.