Python 中是否有用于 TDD 的特定目录结构?
教程讨论测试的内容,但不讨论测试的位置
通过研究 Python Koans,怀疑它是这样的:
/project/main_program.py # This has main method, starts program
/project/classes/<many classes>.py
/project/main_test.py # This simply directs unittest onto tests, can use parameters fed to it to customise tests for environment
/project/tests/<many tests>.py
# to run tests, type "python -m unittest main_test.py" (into a terminal)
# to run program, type "python main_program.py"
我这样做对吗?有没有一个很好的指南来教授 TDD 的目录层次结构?我听说混合代码和测试文件很糟糕。
参考:
-
对于刚接触测试的经验丰富的程序员来说,是否有任何好的 TDD 在线教程? https://stackoverflow.com/questions/1126173/are-there-any-good-online-tutorials-to-tdd-for-an-experienced-programmer-who-is# 编码道场?嗯...也许我会创建一个编码道场网站...
-
http://onlamp.com/pub/a/python/2004/12/02/tdd_pyunit.html http://onlamp.com/pub/a/python/2004/12/02/tdd_pyunit.html#显示混合文件
-
http://www.youtube.com/watch?v=sD6qzJNQEpE http://www.youtube.com/watch?v=sD6qzJNQEpE#尽管 pyTDDmon 看起来很棒,但我想先了解基础知识 =) 这也是一个混合文件
-
http://www.slideshare.net/Skud/test-driven-development-tutorial http://www.slideshare.net/Skud/test-driven-development-tutorial#仅解释“设计测试实施测试重复”。
-
http://blog.cerris.com/category/django-tdd/ http://blog.cerris.com/category/django-tdd/#还是没有帮助...
- http://docs.python.org/library/unittest.html http://docs.python.org/library/unittest.html
根据您的项目,无论哪种风格都可以
- 将实现代码与测试代码分开
- 轻松创建新测试
- 在一项操作中运行所有测试(例如回归测试)
python koans/等只是指导方针。最后,您希望在单元测试中坚持 DRY,并能够轻松、可维护且直观地进行测试。最后由您决定文件夹结构。
我觉得你过于关注满足惯例而不是满足你的项目。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)