如何使用 pytest-bdd 和 pytest 使用 python 编写简单测试?

How do I write a simple test using pytest-bdd and pytest using python?

我对 BDD 很陌生。我在 Windows7 中安装了 pytest-bddpython 3.6。有人可以给出 pytest-bdd 实现测试的简单示例吗?我无法在互联网上找到合适的解决方案。

他们的文档中有一个示例,here. In it, the lay out the creation of a 'feature file,' which seems to be (I admittedly haven't used pytest-bdd) where they piggyback off of pytest, which discovers the file by its name, 'test_publish_article.py'. Each feature file seems intended to isolate a single feature via it's described behavior ('given', 'and', 'when', 'then'), which is programmatically provided by decorators, e.g. @given(). Since this particular example is looking at the behavior of a website, upon which actions can be simulated via splinter, it seems they're grabbing a 'browser' fixture from pytest-splinter 将 pytest 与 splinter 集成。

这有帮助吗,还是您需要更多?