JtR*_*JtR 132 python testing bdd
哪些是最先进的框架和工具,可用于python实践行为驱动开发?特别是找到类似rspec和mocha的类似工具的红宝石会很棒.
小智 48
生菜意味着成为一个类似黄瓜的python工具:http://lettuce.it/
您可以在github.com/gabrielfalcao/lettuce获取源代码
Rya*_*yan 37
Ian Bicking建议将doctest用于行为驱动设计:
我个人倾向于在行为驱动的设计风格中使用鼻子和空洞模拟.具体来说,鼻子的spec 插件非常适合BDD.
Dou*_*ata 29
我建议你使用一套工具来帮助程序员实践BDD和TDD.该工具集由:pycukes,specloud,ludibrio和should-dsl组成.
应该DSL会给你RSpec般的期望.您可以使用RSpec期望API执行的所有操作,ds-dsl也可以.你可以从Github获取最新版本.
SpecLoud可帮助您运行类似BDD的单元测试.你可以通过这样做来安装它
pip install specloud
Run Code Online (Sandbox Code Playgroud)
Ludibrio是一个测试双打(Mocks,Stubs和Dummies)的图书馆.通过安装它
pip install ludibrio
Run Code Online (Sandbox Code Playgroud)
而PyCukes是BDD的主要工具.它将运行场景等.再次,
pip install pycukes
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请阅读PyPi上的工具文档.
小智 8
Pyccuracy项目旨在为Python中的BDD提供特定于域的语言.
与在API级别工作的doctest不同,它对更高级别的操作进行编码,例如加载网页和提交表单.我没有使用它,但如果你正在寻找它,它看起来有点有希望.
试试pyspecs.在开发过程中使测试易于阅读和持续运行是我创建此项目的两个主要目标.
from pyspecs import given, when, then, and_, the, this
with given.two_operands:
a = 2
b = 3
with when.supplied_to_the_add_function:
total = a + b
with then.the_total_should_be_mathmatically_correct:
the(total).should.equal(5)
with and_.the_total_should_be_greater_than_either_operand:
the(total).should.be_greater_than(a)
the(total).should.be_greater_than(b)
with when.supplied_to_the_subtract_function:
difference = b - a
with then.the_difference_should_be_mathmatically_correct:
the(difference).should.equal(1)
Run Code Online (Sandbox Code Playgroud)
# run_pyspecs.py
| • given two operands
| • when supplied to the add function
| • then the total should be mathmatically correct
| • and the total should be greater than either operand
| • when supplied to the subtract function
| • then the difference should be mathmatically correct
(ok) 6 passed (6 steps, 1 scenarios in 0.0002 seconds)
Run Code Online (Sandbox Code Playgroud)