Open8
BDD(振る舞い型駆動開発)をpythonでやるためのbehaveを動かしてみる
今回試したものを置いとくリポジトリ
behaveはここ
BDDは人間が解釈しやすい自然言語っぽいGherkinというフォーマットでテストを定義する手法。
behaveはそれをpythonで実現するためのライブラリ。
とりあえずTutorial
src/featuresディレクトリ作ってtutorial.featureを作る
features/stepsとtutorial.pyを作成
build
docker build -t behave-python-try .
run
docker run --rm --name behave-python-try -v $(pwd)/src:/src behave-python-try behave
# docker run --rm --name behave-python-try -v $(pwd)/src:/src behave-python-try behave
Feature: showing off behave # features/tutorial.feature:1
Scenario: run a simple test # features/tutorial.feature:3
Given we have behave installed # features/steps/tutorial.py:3
When we implement a test # features/steps/tutorial.py:7
Then behave will test it for us! # features/steps/tutorial.py:11
1 feature passed, 0 failed, 0 skipped
1 scenario passed, 0 failed, 0 skipped
3 steps passed, 0 failed, 0 skipped, 0 undefined
Took 0m0.000s
うごいた
日本語でも動くか試してみた。
tutorial_jp.featureとtutorial_jp.pyを作って動くことを確認