Search code examples
python-3.xbddpytestwebautomation

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


I am quite new to BDD. I have installed pytest-bdd with python 3.6 in Windows7. Can some one give simple example of test of pytest-bddimplementation? I am not able to find proper solution for this on internet.


Solution

  • They have an example in their documentation, 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 to integrate pytest with splinter.

    Is that helpful, or do you need more?