This project is an implementation of the String Calculator TDD Kata, completed as part of a technical assessment for Incubyte. The goal was to demonstrate proficiency in Test-Driven Development (TDD) and showcase clean, well-tested code.
The project adheres strictly to TDD principles, with each feature developed through a cycle of writing a failing test, implementing the minimal code to pass the test, and then refactoring. The commit history reflects this process, with frequent commits showing the evolution of the code with each step of TDD.
Create a simple String Calculator with a method add(String numbers)
that takes a string of comma-separated numbers and returns their sum.
- Empty string returns 0
- Single number returns its value
- Two numbers separated by comma returns sum
- Support for multiple numbers
- Handle newlines between numbers
- Support different delimiters
- Negative numbers throw exception
string_calculator/
├── lib/
│ └── main.dart # StringCalculator implementation
├── test/
│ └── string_calculator_test.dart # Test cases
└── pubspec.yaml # Project dependencies
- Clone the repository:
git clone https://github.com/AmriteshTrikon/string_calculator.git
cd string_calculator
- Install dependencies:
dart pub get
To run all tests:
dart test
For detailed test output:
dart test -r expanded
-
Basic Tests
- Empty string returns 0
- Single number returns value
- Two numbers return sum
-
Advanced Features
- Multiple numbers
- Newline handling
- Custom delimiters
- Negative number validation
Click to see test results
[https://drive.google.com/drive/folders/1WiSnktN_ZJ_sY_-QpEQm_V5hjwxGMoHA?usp=sharing]
This project strictly follows Test-Driven Development principles:
- ✍️ Write a failing test
- ✅ Write minimal code to pass
- 🔄 Refactor
- 🔁 Repeat
Amritesh Khare
- Incubyte for the TDD kata challenge
- Dart community for the testing framework