Posts

Showing posts with the label Python

Behavior-Driven Development (BDD) with Python Behave: A Complete Tutorial

Image
This comprehensive Python Behave tutorial teaches you Behavior-Driven Development (BDD) step by step using real examples. You’ll learn how to write Gherkin feature files, implement step definitions in Python, structure a Behave project, and run automated tests — preparing you for real-world test automation using BDD. Table of Content 1. What is BDD? 2. What is Gherkin Language in BDD? 3. What is Behave in Python? 4. Installing and Setup Behave 5. Project Structure for Behave Python (BDD) 6. Feature Files, Step Functions and Other Files in Behave Feature File Step Functions Step Parameters Passing String Param from Feature File Passing Integer Param from Feature File environment.py file behave.ini file 7. Run Feature files in Behave Run a single feature file Run multiple feature files Generate JUNIT xml reports with behave Run feature files with Python suite file Upcoming Tutorials: 8. API Automation Testing with BDD Python (Behave) 9. Selenium Automation with BDD Python (Behave) 1. Wha...

Exploring Modules and Packages in Python: Building Reusable Code Components

Image
1. What are Modules in Python? In Python, a module is a file containing Python code. It can be a Python file (with .py extension) or a compiled Python file (with .pyc extension). It contains functions, classes, and variables that can be used by other Python programs. Modules help us to organize our code into separate files, which can be used in other programs, making our code more reusable. Table of Contents Modules - What are modules? - Creating and importing modules - Importing specific functions or variables from a module Standard Library Modules - Commonly used modules (e.g. math, random, os, sys) - Overview of their functions and capabilities Packages - What are packages? - Creating and importing packages Custom Modules and Packages - Writing your own modules and packages - Organizing code into reusable components 1.1. Creating a Module To create a module, we simply need to create a Python file with .py extension and add our functions, classes, and variables in it. Example: creat...