Jac*_*ing 35 python integration-testing unit-testing
使用单元测试构建Python包的最常用方法如下:
package/
__init__.py
module_1.py
module_2.py
module_n.py
test/
__init__.py
test_module_1.py
test_module_2.py
test_module_n.py
Run Code Online (Sandbox Code Playgroud)
我想区分单元测试(方法和功能)和集成测试(使用整个包并可能涉及其他资源).也许这些测试应该在不同的包中,具有不同的文件名,和/或包括某些文档字符串注释.
这样做是否有标准惯例?
run*_*g.t 22
在我们的项目中,我们在每个包中都有单元测试,与您的情况相同,集成测试,系统测试,作为顶层的单独包,即:
package_1/
__init__.py
module_1.py
module_n.py
test/
__init__.py
test_module_1.py
test_module_n.py
package_n/
__init__.py
module_1.py
module_n.py
test/
__init__.py
test_module_1.py
test_module_n.py
systemtest/
__init__.py
systemtest_1.py
systemtest_n.py
Run Code Online (Sandbox Code Playgroud)
即使你在项目中只有一个包,我也会使用这个约定.但是我不确定这是否是标准惯例.
我刚刚自己研究了一下,发现这个建议很有帮助:
\n\nproject/\n\xe2\x94\x82\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 my_app/\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 __init__.py\n\xe2\x94\x82\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 tests/\n |\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 unit/\n | \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 __init__.py\n | \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 test_sum.py\n |\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 integration/\n |\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 example_data/\n | \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 test_basic.json\n | \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 test_complex.json\n |\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 __init__.py\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 test_integration.py\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
3721 次 |
| 最近记录: |