質問
行動駆動開発を実践するためにPythonで利用できる最も高度なフレームワークとツールはどれですか?特に、ルビー用のrspecやmochaと同様のツールを見つけることは素晴らしいことです。
解決
Ian Bicking は、 doctest 動作駆動設計の場合:
個人的には voidspaceモック行動主導のデザインスタイル。具体的には、仕様鼻のプラグインはBDDに最適です。
他のヒント
Lettuceは、Python用のキュウリのようなツールであることを意味します。 http://lettuce.it/
github.com/gabrielfalcao/lettuceでソースを取得できます
動作をお勧めします。
Python用のCucumberクローンを探して、レタスの使用を開始しましたが、かなり不器用に設計されたレプリカであることがわかりました。非常に素朴です。
その後、私は振る舞いを発見し、それに満足しています。
プログラマーがBDDおよびTDDを実践するのを支援するために開発された一連のツールを使用することをお勧めします。このツールセットは、 pycukes 、 specloud 、 ludibrio および should-dsl 。
Should-DSL は、RSpecのような期待を与えます。 RSpec期待APIでできることはすべて、should-dslでもできます。 Githubの最新バージョンを取得できます。
SpecLoud は、BDDに似た単体テストの実行に役立ちます。次のようにしてインストールできます
pip install specloud
Ludibrio は、テストダブル(モック、スタブ、ダミー)用のライブラリです。
でインストールしますpip install ludibrio
そして PyCukes はBDDのメインツールです。シナリオなどを実行します。再び、
pip install pycukes
詳細については、 PyPi のツールドキュメントをご覧ください。
" sure" を使用して、表現力のあるアサーションを使用できます(RSpecと同様)
Pyccuracyプロジェクトは、PythonでBDDにドメイン固有の言語を提供する取り組みです。
APIレベルで動作するdoctestとは異なり、Webページの読み込みやフォームの送信などの高レベルの操作をエンコードします。私はそれを使用していませんが、それがあなたが探しているものであるならば、それはいくらか有望に見えます。
Pyccuracy が大好きです。最近、中規模のプロジェクトに実装しています。
pyspecs を試してください。開発中にテストを読みやすくし、常に実行することが、このプロジェクトを作成する際の2つの主な目標でした。
テストコード:
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_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)