Test-Driven Developmentjoshilewis.github.io/ELEN7045/TDD.pdf · Test-Driven Development Joshua...
Transcript of Test-Driven Developmentjoshilewis.github.io/ELEN7045/TDD.pdf · Test-Driven Development Joshua...
![Page 1: Test-Driven Developmentjoshilewis.github.io/ELEN7045/TDD.pdf · Test-Driven Development Joshua Lewis @joshilewis. What is a test? Unit Tests. Given When I add 2 and 3 Then The sum](https://reader036.fdocuments.net/reader036/viewer/2022071000/5fbc1d64fd0bc9735441160a/html5/thumbnails/1.jpg)
Test-DrivenDevelopment
Joshua Lewis
@joshilewis
![Page 2: Test-Driven Developmentjoshilewis.github.io/ELEN7045/TDD.pdf · Test-Driven Development Joshua Lewis @joshilewis. What is a test? Unit Tests. Given When I add 2 and 3 Then The sum](https://reader036.fdocuments.net/reader036/viewer/2022071000/5fbc1d64fd0bc9735441160a/html5/thumbnails/2.jpg)
![Page 3: Test-Driven Developmentjoshilewis.github.io/ELEN7045/TDD.pdf · Test-Driven Development Joshua Lewis @joshilewis. What is a test? Unit Tests. Given When I add 2 and 3 Then The sum](https://reader036.fdocuments.net/reader036/viewer/2022071000/5fbc1d64fd0bc9735441160a/html5/thumbnails/3.jpg)
What is a test?
![Page 4: Test-Driven Developmentjoshilewis.github.io/ELEN7045/TDD.pdf · Test-Driven Development Joshua Lewis @joshilewis. What is a test? Unit Tests. Given When I add 2 and 3 Then The sum](https://reader036.fdocuments.net/reader036/viewer/2022071000/5fbc1d64fd0bc9735441160a/html5/thumbnails/4.jpg)
Unit Tests
![Page 5: Test-Driven Developmentjoshilewis.github.io/ELEN7045/TDD.pdf · Test-Driven Development Joshua Lewis @joshilewis. What is a test? Unit Tests. Given When I add 2 and 3 Then The sum](https://reader036.fdocuments.net/reader036/viewer/2022071000/5fbc1d64fd0bc9735441160a/html5/thumbnails/5.jpg)
Given
When I add 2 and 3
Then The sum is 5
![Page 6: Test-Driven Developmentjoshilewis.github.io/ELEN7045/TDD.pdf · Test-Driven Development Joshua Lewis @joshilewis. What is a test? Unit Tests. Given When I add 2 and 3 Then The sum](https://reader036.fdocuments.net/reader036/viewer/2022071000/5fbc1d64fd0bc9735441160a/html5/thumbnails/6.jpg)
Test-Driven Development
![Page 7: Test-Driven Developmentjoshilewis.github.io/ELEN7045/TDD.pdf · Test-Driven Development Joshua Lewis @joshilewis. What is a test? Unit Tests. Given When I add 2 and 3 Then The sum](https://reader036.fdocuments.net/reader036/viewer/2022071000/5fbc1d64fd0bc9735441160a/html5/thumbnails/7.jpg)
Test-Driven Development
![Page 8: Test-Driven Developmentjoshilewis.github.io/ELEN7045/TDD.pdf · Test-Driven Development Joshua Lewis @joshilewis. What is a test? Unit Tests. Given When I add 2 and 3 Then The sum](https://reader036.fdocuments.net/reader036/viewer/2022071000/5fbc1d64fd0bc9735441160a/html5/thumbnails/8.jpg)
public void UnitTest(){
int[] inputs = new[] {2, 3};int expectedOutput = 5;
int actualOutput = Add(inputs);
bool passed = actualOutput == expectedOutput;}
![Page 9: Test-Driven Developmentjoshilewis.github.io/ELEN7045/TDD.pdf · Test-Driven Development Joshua Lewis @joshilewis. What is a test? Unit Tests. Given When I add 2 and 3 Then The sum](https://reader036.fdocuments.net/reader036/viewer/2022071000/5fbc1d64fd0bc9735441160a/html5/thumbnails/9.jpg)
Code Demo
![Page 10: Test-Driven Developmentjoshilewis.github.io/ELEN7045/TDD.pdf · Test-Driven Development Joshua Lewis @joshilewis. What is a test? Unit Tests. Given When I add 2 and 3 Then The sum](https://reader036.fdocuments.net/reader036/viewer/2022071000/5fbc1d64fd0bc9735441160a/html5/thumbnails/10.jpg)
![Page 11: Test-Driven Developmentjoshilewis.github.io/ELEN7045/TDD.pdf · Test-Driven Development Joshua Lewis @joshilewis. What is a test? Unit Tests. Given When I add 2 and 3 Then The sum](https://reader036.fdocuments.net/reader036/viewer/2022071000/5fbc1d64fd0bc9735441160a/html5/thumbnails/11.jpg)
Why do TDD?
![Page 12: Test-Driven Developmentjoshilewis.github.io/ELEN7045/TDD.pdf · Test-Driven Development Joshua Lewis @joshilewis. What is a test? Unit Tests. Given When I add 2 and 3 Then The sum](https://reader036.fdocuments.net/reader036/viewer/2022071000/5fbc1d64fd0bc9735441160a/html5/thumbnails/12.jpg)
Executable Specification
![Page 13: Test-Driven Developmentjoshilewis.github.io/ELEN7045/TDD.pdf · Test-Driven Development Joshua Lewis @joshilewis. What is a test? Unit Tests. Given When I add 2 and 3 Then The sum](https://reader036.fdocuments.net/reader036/viewer/2022071000/5fbc1d64fd0bc9735441160a/html5/thumbnails/13.jpg)
Living Documentation
![Page 14: Test-Driven Developmentjoshilewis.github.io/ELEN7045/TDD.pdf · Test-Driven Development Joshua Lewis @joshilewis. What is a test? Unit Tests. Given When I add 2 and 3 Then The sum](https://reader036.fdocuments.net/reader036/viewer/2022071000/5fbc1d64fd0bc9735441160a/html5/thumbnails/14.jpg)
Focus
![Page 15: Test-Driven Developmentjoshilewis.github.io/ELEN7045/TDD.pdf · Test-Driven Development Joshua Lewis @joshilewis. What is a test? Unit Tests. Given When I add 2 and 3 Then The sum](https://reader036.fdocuments.net/reader036/viewer/2022071000/5fbc1d64fd0bc9735441160a/html5/thumbnails/15.jpg)
TDD is a design tool
![Page 16: Test-Driven Developmentjoshilewis.github.io/ELEN7045/TDD.pdf · Test-Driven Development Joshua Lewis @joshilewis. What is a test? Unit Tests. Given When I add 2 and 3 Then The sum](https://reader036.fdocuments.net/reader036/viewer/2022071000/5fbc1d64fd0bc9735441160a/html5/thumbnails/16.jpg)
Automated regression testing
![Page 17: Test-Driven Developmentjoshilewis.github.io/ELEN7045/TDD.pdf · Test-Driven Development Joshua Lewis @joshilewis. What is a test? Unit Tests. Given When I add 2 and 3 Then The sum](https://reader036.fdocuments.net/reader036/viewer/2022071000/5fbc1d64fd0bc9735441160a/html5/thumbnails/17.jpg)
In a single phrase? TDD increases productivity because the hard part of programming is thinking, and TDD makes thinking faster.
- Michael Hill (GeePawHill)
![Page 18: Test-Driven Developmentjoshilewis.github.io/ELEN7045/TDD.pdf · Test-Driven Development Joshua Lewis @joshilewis. What is a test? Unit Tests. Given When I add 2 and 3 Then The sum](https://reader036.fdocuments.net/reader036/viewer/2022071000/5fbc1d64fd0bc9735441160a/html5/thumbnails/18.jpg)
TDD like satellite navigation
![Page 19: Test-Driven Developmentjoshilewis.github.io/ELEN7045/TDD.pdf · Test-Driven Development Joshua Lewis @joshilewis. What is a test? Unit Tests. Given When I add 2 and 3 Then The sum](https://reader036.fdocuments.net/reader036/viewer/2022071000/5fbc1d64fd0bc9735441160a/html5/thumbnails/19.jpg)
TDD is NOT about testing
1. Specification2. Living documentation3. Design4. Automated testing
![Page 20: Test-Driven Developmentjoshilewis.github.io/ELEN7045/TDD.pdf · Test-Driven Development Joshua Lewis @joshilewis. What is a test? Unit Tests. Given When I add 2 and 3 Then The sum](https://reader036.fdocuments.net/reader036/viewer/2022071000/5fbc1d64fd0bc9735441160a/html5/thumbnails/20.jpg)
More Resources
• TDD by Example – Kent Beck• Katas• Code Retreats
![Page 21: Test-Driven Developmentjoshilewis.github.io/ELEN7045/TDD.pdf · Test-Driven Development Joshua Lewis @joshilewis. What is a test? Unit Tests. Given When I add 2 and 3 Then The sum](https://reader036.fdocuments.net/reader036/viewer/2022071000/5fbc1d64fd0bc9735441160a/html5/thumbnails/21.jpg)
TDD Recap
No code without a failing test
Simplest possible thing
Red Green Refactor