Lemoncheesecake is a very well known Python testing framework. As a test automation services company, we have evaluated this framework for one of your automation testing projects. After the proof of concept stage, we decided to use lemoncheesecake framework to write automation test scripts. Initially, BDD support was not available. However, now you can use behave BDD framework in lemoncheesecake. In this blog article, you will learn how to write BDD tests using lemoncheesecake and behave frameworks.
Step #1: Installation
To setup BDD using behave and lemoncheesecake, you need only two dependencies (behave and lemoncheesecake packages). That’s it.
pip install lemoncheesecake pip install behave
Step #2: Setup LemonCheeseCake Project
Once the required dependencies are installed, you need to create LemonCheeseCake project. There is a command to do that. Run the below command. It will create LemonCheeseCake (LCC) project for you.
lcc bootstrap myproject
Step #3: Create a Feature
Create ‘features’ folder inside ‘myproject’ folder. Create a feature file inside the features folder.
Feature: LemonCheeseCake Demo Scenario: Demo Scenario Given I fill login details When I click login button Then I should see Home page
Step #4: Step Definition
from behave import * import lemoncheesecake.api as lcc from lemoncheesecake.matching import * @given("I fill login details") def step_impl(context): lcc.log_info("Pass") @when("I click login button") def step_impl(context): lcc.log_info("Pass") @then("I should see Home page") def step_impl(context): lcc.log_info("Pass")
Step #4: Create environment.py
Create environment.py inside myproject folder to install BDD hooks from behave.
from lemoncheesecake.bdd.behave import install_hooks install_hooks()
Step #5: Run
Once the execution is complete, you can find LCC HTML report in reports folder. The best thing about LCC is reporting. Your team will love it once they start getting reports from LemonCheeseCake framework.