<aside>
</aside>
@given
๋ฐ์ฝ๋ ์ดํฐ์ ๋ค์ํ ๋ฐ์ดํฐ ์์ฑ ์ ๋ต(Strategy)์ผ๋ก ๋ฐ์ดํฐ ์ฃผ์
๋ฐฉ๋ฒ ์๊ธฐํ๋ก์ ํธ ๊ตฌ์กฐ:
graph TD
A(my-pytest-project) --> B(.venv);
A --> C(mycalc);
A --> D(tests);
A --> E(pytest.ini);
C --> C1(__init__.py);
C --> C2(calculator.py);
C --> C3(exchange.py);
D --> D1(__init__.py);
D --> D2(test_calculator.py);
D --> D3(conftest.py);
D --> D4(test_scopes.py);
D --> D5(test_markers.py);
D --> D6(test_exchange.py);
D --> D7(test_properties.py Hypothesis ํ
์คํธ ํ์ผ);
style B fill:#eee,stroke:#333,stroke-dasharray: 5 5;
style C fill:#ccf,stroke:#333;
style D fill:#cfc,stroke:#333;
style E fill:#fef,stroke:#333;
style C2 fill:#cce,stroke:#333;
style C3 fill:#fda,stroke:#333;
style D2 fill:#cef,stroke:#333;
style D3 fill:#fec,stroke:#333;
style D4 fill:#dff,stroke:#333;
style D5 fill:#ffd,stroke:#333;
style D6 fill:#adf,stroke:#333;
style D7 fill:#dff,stroke:#333;
mycalc/calculator.py
: (๊ณฑ์
๋ฉ์๋์ ์๋์ ์ธ ๋ฒ๊ทธ ์ถ๊ฐ)tests/test_properties.py
(Hypothesis ํ
์คํธ ์์ ):assert add(2,3) == 5
)graph TD
subgraph Example-Based Testing
direction LR
A["๊ฐ๋ฐ์ ์์ ์ ์ (2,3) -> 5"] --> B{ํ
์คํธ ์คํ};
B -- ๊ฐ ์์ ๊ฒ์ฆ --> C[๊ฒฐ๊ณผ ํ์ธ ์ ์ ๋ ์์๋ง];
end
subgraph Property-Based Testing
direction LR
D["๊ฐ๋ฐ์ ์์ฑ ์ ์ add(x,y)==add(y,x)"] --> E{"๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋ฐ์ดํฐ ์์ฑ (0,0),(-1,5)..."};
E -- ๊ฐ ๋ฐ์ดํฐ๋ก ์์ฑ ๊ฒ์ฆ --> F{๋ฐ๋ก ์คํจ ์ผ์ด์ค ์ฐพ๊ธฐ};
F -- ๋ฐ๋ก ๋ฐ๊ฒฌ --> G[๊ฒฐ๊ณผ ๋ณด๊ณ ๋ฒ๊ทธ ๊ฐ๋ฅ์ฑ];
F -- ๋ฐ๋ก ๋ชป ์ฐพ์ --> H[๊ฒฐ๊ณผ ๋ณด๊ณ ์์ฑ ๋ง์กฑ];
end
style C fill:#cfc, stroke:#333
style G fill:#fcc, stroke:#333
style H fill:#cfc, stroke:#333