Pythonによるテスト入門
Alexander Levin
Data Scientist
結合テスト:相互作用が正常に動作するかを検証するソフトウェアテスト手法。
結合:システム内の2つ以上のモジュール間の相互作用。

例:
起こり得る結合の問題:
import pytest, os
@pytest.fixture
def setup_file():
# Create temporary file
file = "test_file.txt"
with open(file, "w") as f1:
f1.write("Test data 1")
yield file
os.remove(file)
def test_fs(setup_file):
file = setup_file
# Check that the file was created successfully
assert os.path.exists(file)
結合テスト:結合が期待どおり動作するかを検証する手法。
実プロジェクトには多様な結合が多数含まれる。
結合テストは多くの潜在的問題の予防に役立つ。
例:Pythonとファイルシステム間の結合を確認。
Pythonによるテスト入門