- jUnit : assertArray / asertThrows
- checkStyle : ์ฝ๋ฉ ์คํ์ผ ์ ๋
- Doxygen : ์์กด์ฑ ๋ถ์(๋ค์ด์ด๊ทธ๋จ)
# 1. JUnit ํ๋จ๊ณ ๋ ๋์๊ฐ๊ธฐ
์์ธ๊ฐ ๋ฐ์ํ๋์ง ํ์ธํ๊ณ ๊ทธ ๋ฉ์ธ์ง๋ฅผ exception์ ์ ์ฅํด์ ์ฐ๋ฆฌ๊ฐ ์ํ๋ ์๋ฌ ๋ฌธ์์ ์ผ์นํ๋์ง๊น์ง ํ์ธํ๊ธฐ!
@Test
void testDivide() throws Exception {
// assertEquals(0.5, calculator.divide(2.0, 4.0));
assertThrows(Exception.class, () ->
calculator.divide(4, 0), "0 ์์ธ ์ฒ๋ฆฌ ๋ฐ์"
);
// calculator.divide(4, 0)์คํ ์, Exception ์ฌ๋ถ๋ง ํ์ธ
}
// ์ฌ๋ถ๋ง ํ์ธํ๋๊ฒ ์๋๋ผ ๋ฌธ์๊ฐ ๋์ค๋์ง ํ์ธ
@Test
public void testDevide_exception() throws Exception {
Exception exception = assertThrows(Exception.class, () ->
calculator.divide(4, 0), "0 ์์ธ ์ฒ๋ฆฌ ๋ฐ์"
);
assertEquals("Divide Error", exception.getMessage());
}
์ ์ ๋ถ์ ์ฝ๋ ๋๋ฆฌ๊ธฐ : SonarQube(java๋ ๋ฌด๋ฃ) - pmd, checkstyle
1. ๊ฐ์ธ์ ์ธ ํด๋ ๋ด์์ eclipse, Intellij์์ ๋๋ฆฌ๋ฉด SonarLint
2. git์ ํต์ฒด๋ก ์ฌ๋ ธ์๋๋ SonarQube(์๋ฒ) ํ์ฌ ์ ์ฒด ๋ด๋ถ์ ์ฝ๋๋ฅผ ๋ณผ ์ ์์
3. Jenkins CI/CD์์ buildํ ๋ SonarQube ์ฌ์ฉํ ์๋ ์์
JUnit์ ๋จ์ ํ ์คํธ๋ฅผ ์ํ ๋๊ตฌ์ด๊ณ ์น/์ฑ์์๋ ๊ทธ๋ ๊ฒ ํ์์ ์ด์ง๋ ์๋ค!!
# assertArray ์ฌ์ฉ!!
package com.calc;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.Arrays;
import org.junit.jupiter.api.Test;
class CalculatorTest_format {
Calculator calculator = new Calculator();
// assertEquals : ๊ฐ๋ณ ์์ ๊ฒ์ฆ
@Test
void testParseInput_individualCheck() throws Exception {
String[] result = calculator.parseInput("2 + 3");
assertEquals("2", result[0]);
assertEquals("+", result[1]);
assertEquals("3", result[2]);
}
// assertEquals : List ๋ก ๊ฒ์ฆ
@Test
void testParseInput_listCheck() throws Exception {
String[] result = calculator.parseInput("2 + 3");
assertEquals(Arrays.asList("2", "+", "3"), Arrays.asList(result));
}
// assertEquals
@Test
void testParseInput_array() throws Exception {
String[] result = calculator.parseInput("2 + 3");
assertArrayEquals(new String[] {"2", "+", "3"}, result, "๋ฐฐ์ด์ด ์์ ๊ฐ๊ณผ ๋ค๋ฆ
๋๋ค");
}
// null, empty ์ฒ๋ฆฌ ์ฌ๋ถ ํ์ธ
@Test
void testParseInput_nullAndEmpty() throws Exception {
Exception nullException =
assertThrows(Exception.class, () ->
calculator.parseInput(null));
assertEquals("null์ ์
๋ ฅ ๋ถ๊ฐ", nullException.getMessage());
}
}
# checkStyle ์ ์ฉํ๊ธฐ




# doxygen (์์กด๊ด๊ณ ํ์
๋ถ์ํ๊ณ ์๊ฐํํ์ง๋ง ๊ฐ๋ตํจ)
์์กด์ฑ ๋ถ์
- ๊ฐ์
- ํจ์ ๋ณ์์ ํธ์ถ๊ด๊ณ๋ฅผ ๋ถ์ํ๋ ๋๊ตฌ
- ๋๊ตฌ๊ฐ ์ถ๊ตฌํ๋ ๋ฐฉํฅ์ ๋ฐ๋ผ ํจํค์ง ํด๋์ค(ํ์ผ) ํจ์ ๋จ์๋ก ํํ
- ๋ชฉ์
- ์ํคํ
์ฒ ๊ตฌ์กฐ์์ ์๋ธ ์์คํ
๊ฐ์ ์์กด์ด ์ ์ ํ์ง ํ์ธ
- ์๋ธ ์์คํ ๋ ์ด์ด์์ ๊ฐ ๋ ์ด์ด ๊ฐ ํธ์ถ๊ด๊ณ
- ์๋ธ ์์คํ ๋ ๋ฒจ์์ ๊ฐ ๋ ๋ฒจ ๊ฐ ํธ์ถ ๊ด๊ณ
- ์ํ์์กด์ฑ(์ํธ ์ฐธ์กฐ)๊ด๊ณ
- ๊ฐ์ฒด์งํฅ์ ํนํ๋์ด, ์ถ์ํ์ ๊ตฌ์ ์ดค์ ์ ๋๋ฅผ ํ์ธ
- ์ํคํ
์ฒ ๊ตฌ์กฐ์์ ์๋ธ ์์คํ
๊ฐ์ ์์กด์ด ์ ์ ํ์ง ํ์ธ

https://www.doxygen.nl/download.html#google_vignette
Doxygen download
Download Doxygen Free and open source software
www.doxygen.nl
# graphvie(Doxygen์ ๋ถ์ ๊ฒฐ๊ณผ๋ฅผ ์ข๊ฒ ์๊ฐํ ํ๋ ๋๊ตฌ, ์ฐ์ถ๋ฌผ ์ ์ถ์ ์ฉ์ดํจ)
https://graphviz.org/download/
Download
Source Code Source code packages for the latest stable and development versions of Graphviz are available, along with instructions for anonymous access to the sources using Git. Executable Packages Packages marked with an asterisk(*) are provided by outsid
graphviz.org




