Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
2 Antworten
213 Ansichten

Hi,

I’ve developed a new Odoo module, and it’s working well. However, I’d like to implement custom BDD test scenarios. Could you guide me on how to implement and use BDD within the module?

Avatar
Verwerfen
Beste Antwort

Hi,


You can implement Behavior-Driven Development (BDD) in your Odoo module to make your tests more descriptive and business-oriented. While Odoo primarily uses Python’s built-in unittest framework, it is fully compatible with external BDD tools such as Behave or pytest-bdd. This allows you to write functional tests in plain English that clearly describe user behavior and expected outcomes.


To get started, you need to install a BDD testing library (for example, by running pip install behave). Then, within your custom module, create a tests folder that contains both your .feature files (written in Gherkin syntax) and their corresponding step definition files in Python. The feature files describe scenarios like “creating a customer,” while the step definitions connect these actions to actual Odoo operations using its ORM.


For example, you can define steps such as logging in as an administrator, creating a customer, and verifying the customer’s presence in the database. You can execute these tests independently using the behave command or integrate them into Odoo’s automated test runner by invoking Behave from a Python test file. This setup helps you maintain clear, reusable, and readable tests that focus on business logic rather than technical implementation.


For official documentation and guidance, you can refer to:


https://www.odoo.com/documentation/17.0/developer/reference/backend/testing.html


Hope it helps

Avatar
Verwerfen
Beste Antwort

Hi!

You can absolutely implement BDD-style tests (using Gherkin syntax: Given, When, Then) in your custom Odoo module - though Odoo doesn’t natively support BDD by default, you can integrate it using Python testing tools like Behave or pytest-bdd, while leveraging Odoo’s built-in testing framework for the environment setup.

Avatar
Verwerfen