⬆️ ⬇️

BDD Python Framework Comparison: Pros and Cons

Hello. Already this month, the course "Python QA Engineer" starts at OTUS. On the eve of the start of this course, we are sharing with you the translation of interesting material.





Almost all major programming languages ​​have frameworks for BDD testing , and Python is no exception. And in fact, he has several of them! So how do you compare them and which one is the best? Let's try to figure it out.



behave



behave is one of the most popular BDD python frameworks. Despite the fact that it is not officially part of the Cucumber project, its functionality is quite similar to the Cucumber frameworks.



Sources:





Logo





Pros:





Minuses:





pytest-bdd



pytest-bdd is a pytest plugin that allows users to write tests as Gherkin feature files instead of test functions. Because it is integrated into pytest, it can work with any other pytest plugins, such as pytest-html for creating beautiful reports and pytest-xdist for parallel testing. It also uses pytest fixtures for dependency injection.



Sources:





Logo





Pros:





Minuses:





radish



radish is a BDD framework with a twist: it adds a new syntax to the Gherkin language. Language features such as script cycles, script prerequisites, and constants make Gherkin in radish more programmatic for test cases.



Sources:





Logo





Pros:





Minuses:





lettuce



lettuce is another “vegetable” BDD Python framework, which has been known for several years. However, his site and code have not been updated for a long time.



Sources:





Logo:





Pros:





Minuses:





freshen



freshen is one of the very first BDD testing frameworks in Python. He was a plugin for nose . However, freshen and nose are no longer supported, and on the page for their documentation it is clearly said to use other frameworks.



Recommendations



None of these frameworks are perfect, but many of them have significant advantages. In general, I would recommend using pytest-bdd, since it has all the advantages of pytest. I believe that pytest is one of the best frameworks for testing in any language because of its brevity, fixtures, assertions and plug-ins. 2018 Python Developers Survey showed that pytest is the most popular framework for testing and in Python. Although pytest-bdd does not look as polished as behave, I believe that some TLC from the open source community have the power to fix it.

And some more recommendations:





What is your favorite BDD framework? Please share in the comments!



')

Source: https://habr.com/ru/post/460046/



All Articles