- What is TDD?
- What is SOLID?
- Example Application
- Boilerplate Code
- Writing Tests
- Satisfying Tests
- Github Actions
- Coverage Testing
We'll implement a very simple program that can take in a string that represents a list of numbers and returns their sum.
>>> Calculator.add("1,2,3")
6
>>> Calculator.add("10,2")
12
In developing this app, we'll start with the simplest case and gradually expand its scope using TDD.
- Add 0, 1, or 2 arguments. Empty strings return 0.
- Allow adding n arguments.
- Handle newlines in the input string.
- Support different delimiters.
- The first line is optional. All existing scenarios should still be valid.
- Calling the function to add with a negative number should throw an exception
- Numbers greater than 1000 should be ignored.
- Delimiters can be any length with the format:
//[delimiter]\n
e.g.//[---]\n1---2---3
should return 6. - Allow multiple delimiters.
- Make sure multiple delimiters can be of any length.