Python TDD目录结构 [英] Python TDD directory structure
问题描述
Python中是否有用于TDD的特定目录结构?
Is there a particular directory structure used for TDD in Python?
教程只讨论测试的内容,而不是放在何处他们
Tutorials talk about the content of the tests, but not where to place them
通过在Python Koans中戳戳,怀疑其类似以下内容:
From poking around Python Koans, suspect its something like:
/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的目录层次结构?我听说混合使用代码和测试文件是不好的。
Am I doing this right? Is there a good guide which teaches the directory hierarchy for TDD? I heard that having mixed files of code and tests is bad.
参考文献:
- 那里对于有经验的新手来说,对于TDD来说,有什么好的在线TDD教程?#编码dojo?嗯...也许我将开始编写dojo网站...
- http://onlamp.com/pub/a/python/2004/12/02/tdd_pyunit.html #显示混合文件
- http://www.youtube.com/watch?v=sD6qzJNQEpE#和pyTDDmon一样好,我想先了解基础知识=)多数民众赞成在混合文件中
- http://www.slideshare.net/Skud/test-driven-development-tutorial #explains设计测试工具测试重复
- http://blog.cerris .com / category / django-tdd / #仍然没有帮助...
- http://docs.python.org/library/uni ttest.html
- Are there any good online tutorials to TDD for an experienced programmer who is new to testing? # A coding dojo? hmm... Perhaps I'll start a coding dojo website...
- http://onlamp.com/pub/a/python/2004/12/02/tdd_pyunit.html #Shows mixed files
- http://www.youtube.com/watch?v=sD6qzJNQEpE #As great as pyTDDmon looks, I'd like to understand the basics first =) also thats a mixed file
- http://www.slideshare.net/Skud/test-driven-development-tutorial #explains "design test implement test repeat" only..
- http://blog.cerris.com/category/django-tdd/ #Still no help...
- http://docs.python.org/library/unittest.html
推荐答案
根据您的项目,无论哪种样式,您
Based on your project, Whatever style lets you
- 从测试代码中分离实现代码
- 轻松创建新测试
- 一次执行所有测试(例如
python koans / etc只是指导原则。最后,您希望在单元测试中保持DRY,并能够轻松,维护和直观地进行测试。最后由您决定文件夹的结构。
The python koans/etc are just guidelines. In the end you want to uphold DRY with your unittests and be able to test easily, maintainably and intuitively. In the end it is up to you to decide your folder structure.
我觉得您过于关注满足约定而不是满足您的项目。
I feel like you are focusing too much on satisfying convention instead of satisfying your project.
这篇关于Python TDD目录结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!