Skip to content

Example: Add Calculator Module with TDD/BDD (Copilot Demo) #4

@BatraXPankaj

Description

@BatraXPankaj

User Story

As a developer using this template
I want to add a simple calculator module with full TDD/BDD coverage
So that I can demonstrate the development workflow with Copilot assistance

Acceptance Criteria (BDD Scenarios)

Scenario: Calculator performs basic addition
Given a calculator instance
When I add 2 and 3
Then the result should be 5

Scenario: Calculator performs subtraction
Given a calculator instance
When I subtract 3 from 10
Then the result should be 7

Scenario: Calculator handles division by zero
Given a calculator instance
When I divide 10 by 0
Then it should throw a DivisionByZero error
And the error message should be clear

Scenario: Calculator chains operations
Given a calculator instance
When I add 5, then multiply by 2, then subtract 3
Then the result should be 7

Technical Implementation Hints

  • Files to create:
    • src/calculator.ts (or .js, .py, etc based on tech stack)
    • tests/calculator.test.ts (unit tests - TDD)
    • tests/calculator.bdd.ts (BDD scenarios)
  • Test framework: Jest (Node.js) / Pytest (Python) / your choice
  • Functions needed: add(), subtract(), multiply(), divide(), chain()
  • Error handling: Custom error for division by zero
  • Follow: Red → Green → Refactor cycle

Definition of Done

  • Unit tests written first (TDD - Red)
  • BDD scenarios implemented
  • Calculator implementation (Green)
  • Code refactored and cleaned
  • All tests passing
  • Code reviewed
  • Documentation added (JSDoc/docstrings)
  • CI pipeline passes

Priority: Medium
Size: M (4-8 hours)


🤖 This issue is ready for GitHub Copilot assignment!

To assign to Copilot:

  1. Ensure your repository has Copilot enabled
  2. Assign this issue to @github-copilot
  3. Copilot will analyze and create a PR with implementation

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions