Podcast Lookup

🫢 Python Behave BDD

Programmers

  • February 16, 2023
  • 6 min
Episode page
About this episodePython Behave testing
Python Behave testing

Transcript

From the publisher

This transcript comes from the podcast’s own feed, shown as the publisher wrote it.

🫢 Python Behave BDD

00:00—
  1. Hello everyone. Today, we are going to discuss the python behave Library. So, for those of us who are not familiar with it, what is the behave library? And how is it used? The behave is a python library that allows us to write behavior-driven development bdd tests for our python application.

  2. Bdd is a software development methodology that emphasizes collaboration between developers QA teams. Us and stakeholders with behave. We can write tests in claim in English, which makes them easy to understand and maintain even for non-technical stakeholders but what are the disadvantages you ask. Yes there are disadvantages.

  3. First, we introduce a new library into the system, and every time we introduce in the library it comes with, with all the ten you Library, comes the need to maintain it. They need to update it with security patches the learning curve etc. Etc. You know that way. So this is a new library.

  4. There is another cone to using this Library. The con is that once we start writing tests in the behave bdd methodology, it's different. It's not looking like a normal programming language, it's good to write tests. I think it, it makes sense to itse the behave, but once we use it, Then we have to kind of test those that are written in the bdd methodology and those that are written in the let's say, python do you notice? They didn't test library or the pythons Library. So we need to maintain if multiple things. It's, especially useful when we want to provide non-technical people with the ability to Y test because it's written, as we said, in human language.

  5. So So let's say that we are working on an e-commerce websites that they can in example and we want to write tests for the checkout process. So we might run, right. Some feature file in the behave. It's a, it's a finder feature in plain English that describes the behavior of the to want to test.

  6. Of course, the computer would not understand this. Normal language, we would need to provide another file, another couple of files. The environment fight, and then there is that dot steps files, which would translate. But it's pretty easy, it's not that hard. If I made it and you will make it so you add and couple of more files to assist. So when you quite so basically you have one file which is the file dot feature, then you add multiple files that exist in order to test application.

  7. Then you have a global environment file, then you have the step, slide step size and the environment. Five are supporting the dot feature files and how is it looked like, how does the bdd look like the bill DDE? Let's take the feature fight. Looks like this feature checkout process as the customer, I want to be able to check out and pay for my atoms so that I can save my order scenario.

  8. Successful, check out given I have added an item to my cart and I have navigated to the checkout page when I entered shipping and payment, you Mission and they click place order button, then I should see a confirmation message. So, you see, it's pretty like, normal human language and straightforward, but things are not as those easy as it seems because we can, we still need of course to implement everything behind this. So, once we have the feature file written, we use the behave library, to generate the step definitions, which are the code that actually executes this test at the test. And we would need to fill fill in the steps. And once we run the tests using behave in the command line, it will read our feature files, match the steps to the appropriate, step definition, and execute the steps. If a test fails behave with provide us with the whole message, of course, So, so, what's the difference? You ask the main difference in

  9. behavior is that it allows us to fight testing plan English, but as we said, of course, we would need to support it. So it's good. If you will need to give the ability to high test, to someone who's not a software developer, which makes it easy to, to, to White test, we tell them what are the abilities, the capabilities, what did the software developer writing, the steps files That day.

  10. Well, I'm not software developers would be able to write such a filter feature files. And let's talk about again about the downsides and limitations of using the behavioral, the behave Library. So, one potential downside, is that writing a feature, files can be time-consuming, especially for complex application because it's not a programming language.

  11. It can also be a challenge to come up with good test scenario. Covers all the relevant functionality and additionally because behave is relatively new library. That might be a few resources available for Learning and troubleshooting compared to the established testing Frameworks.

  12. So the recommendation is to start a service to start small and gradually, see if it fits us and walk away to more complex tests to. So impose the ton to collaborate with multiple people, with the clients would need to use. Use this library and stakeholders and see that everything matches the expectations.