Skip to content

MathiasPaulenko/cookiecutter-example

Repository files navigation

Cookiecutter Hub — Examples, Documentation & Resources

Reference repository for learning, using, and creating templates with Cookiecutter.

Cookiecutter is a CLI tool that generates projects from templates. It defines variables in cookiecutter.json, uses Jinja2 in file names and content, and runs pre/post generation hooks. It is the de facto standard for scaffolding in Python and multi-language projects.


Table of Contents

  1. What is Cookiecutter
  2. Quick Install
  3. How to Use This Repository
  4. Repository Structure
  5. Included Template: Behave BDD
  6. Minimalist Examples
  7. Documentation
  8. Resources
  9. Contributing

What is Cookiecutter

Cookiecutter creates projects from templates interactively or non-interactively. A template is a directory with:

  • cookiecutter.json — defines the variables the user fills in.
  • {{ cookiecutter.project_name }}/ — the template directory (Jinja2 in name and content).
  • hooks/ (optional) — pre_gen_project.py and post_gen_project.py scripts.
# Basic usage
cookiecutter https://github.com/user/cookiecutter-template
# Non-interactive
cookiecutter --no-input https://github.com/user/cookiecutter-template project_name=my-project
# From a local path
cookiecutter ./my-template

Quick Install

pip install cookiecutter
# or with pipx (recommended)
pipx install cookiecutter

Requires: Python 3.7+.


How to Use This Repository

Generate a project from the included Behave BDD template

# Clone this repo
git clone https://github.com/MathiasPaulenko/cookiecutter-example.git
cd cookiecutter-example

# Generate project from the Behave BDD template
cookiecutter .
# or non-interactive:
cookiecutter --no-input . project_name=my_behave_project

Try the minimalist examples

# Basic example
cookiecutter examples/01-minimal/

# Hooks example
cookiecutter examples/02-hooks/

# Choices and conditionals example
cookiecutter examples/03-choices-conditionals/

# Dynamic values and advanced Jinja2 example
cookiecutter examples/04-dynamic-jinja2/

Repository Structure

cookiecutter-example/
├── README.md                      # This file
├── LICENSE                        # Repo license
├── CONTRIBUTING.md                # Contribution guide
├── cookiecutter.json              # Behave template variables
├── hooks/                         # Pre/post generation hooks
├── {{ cookiecutter.project_name }}/  # Full Behave BDD template
│   ├── features/                  # Gherkin features and steps
│   ├── behave.ini                 # Behave configuration
│   ├── requirements.txt           # Conditional dependencies
│   └── README.md
├── docs/                          # Cookiecutter documentation
│   ├── 01-cookiecutter-basics.md
│   ├── 02-template-structure.md
│   ├── 03-hooks-guide.md
│   ├── 04-advanced-jinja2.md
│   ├── 05-best-practices.md
│   └── 06-creating-your-own.md
├── examples/                      # Minimalist demo templates
│   ├── 01-minimal/
│   ├── 02-hooks/
│   ├── 03-choices-conditionals/
│   └── 04-dynamic-jinja2/
└── resources/                     # Resources and links
    ├── cheatsheet.md
    ├── awesome-templates.md
    └── tools-integrations.md

Included Template: Behave BDD Project

This repository includes a real template: Behave BDD Project — a base BDD test automation project using Behave, with optional support for Selenium, Requests, and Allure.

Template features:

  • Variables in cookiecutter.json: project_name, project_description, author_name, python_version, license, use_selenium, use_requests, use_allure, browser, headless, init_git.
  • Structure with features/ (Gherkin), features/steps/ (step definitions), features/environment.py (hooks).
  • behave.ini with default configuration.
  • Pre/post generation hooks: input validation, optional git init.
  • Conditional dependencies based on choices (Selenium, Requests, Allure).

See the template README at {{ cookiecutter.project_name }}/README.md.


Minimalist Examples

Each example in examples/ demonstrates a specific cookiecutter concept:

Example Concept demonstrated
01-minimal/ Minimum viable template structure
02-hooks/ pre_gen_project.py and post_gen_project.py
03-choices-conditionals/ Choice lists, conditional files
04-dynamic-jinja2/ Derived values, Jinja2 filters, slugify

See examples/README.md for details.


Documentation

Full guides in docs/:


Resources


Contributing

Contributions are welcome. See CONTRIBUTING.md.


License

MIT — see LICENSE.

About

Cookiecutter template for generating Behave BDD test automation projects with Selenium, Allure, and configurable options

Topics

Resources

License

Code of conduct

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors