-
Notifications
You must be signed in to change notification settings - Fork 0
Unit Test
GitDeveloperKim edited this page Jul 14, 2022
·
20 revisions
- link
- smoke test : ๋ณธ๊ฒฉ์ ์ธ ํ ์คํธ ์ํ์ ์์ ๊ตฌ์ถ๋ ํ๊ฒฝ์์ ํ ์คํธ๊ฐ ๊ฐ๋ฅํ์ง ํ๋จํ๊ธฐ ์ํ ํ ์คํธ (๋น๋ํ ์คํธ)
- sanity test : ์์ ๋ณํ๋ค์ด ์ฝ๋๋ ๊ธฐ๋ฅ์์ ์ด์๋ฅผ ๋ง๋ค์๋์ง๋ฅผ ํ์ธํ๊ธฐ ์ํ ํ ์คํธ
- canary test : ์๋ก ๊ฐ๋ฐํ sw ๋ฒ์ ์ผ๋ก ๋ชจ๋ ์ฌ์ฉ์๊ฐ ํ๋ฒ์ ๋์ด์ค๋ ๊ฒ์ด ์๋๋ผ ์ด์ ๋ฒ์ ๊ณผ ํผ์ฉํด์ ์ฌ์ฉํ๋ ๋ฐฉ์
unittest official doc
unittest official korean
unittest
unittest blog
coverage
coverage.py
unittest.mock
pytest doc
ํ์ด์ฌ ๋จ์ ํ
์คํธ์ ๋ํ ๊ฐ๋
๋ธ๋ก๊ทธ link
๋ชฉ์ ๋ํ ๊ฐ๋
๋ธ๋ก๊ทธ link
mock ํจ์น์ ๋ํ ๋ธ๋ก๊ทธ link
- python -m pip install coverage
- ๋จ์ํ
์คํธ
python -m unittest -v TestCalculator.py - ์ปค๋ฒ๋ฆฌ์ง
coverage report
coverage html
coverage run --source=src --omit="./test/Test_" -m unittest discover .\test\Test.py
- exception(divide by zero) ์ฌ์ฉํ๊ธฐ : stackoverflow
from unittest.mock import MagicMock
class testClass():
def method(parameter_list):
pass
test_class = testClass()
test_class.method = MagicMock(return_value=10)
test = test_class.method(1, 2, 3, key='value')
print(test)