-
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)