test-driven development learn the "test first" approach to coding softuni team technical...

15
Test-Driven Development Learn the "Test First" Approach to Coding SoftUni Team Technical Trainers Software University http:// softuni.bg High-Quality Code

Upload: rachel-collins

Post on 04-Jan-2016

218 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Test-Driven Development Learn the "Test First" Approach to Coding SoftUni Team Technical Trainers Software University

Test-Driven DevelopmentLearn the "Test First"

Approach to Coding

SoftUni TeamTechnical TrainersSoftware Universityhttp://softuni.bg

High-QualityCode

Page 2: Test-Driven Development Learn the "Test First" Approach to Coding SoftUni Team Technical Trainers Software University

2

Code and Test

Test-Driven Development

Reasons to use TDD

Myths and Misconceptionsabout TDD

Table of Contents

Page 3: Test-Driven Development Learn the "Test First" Approach to Coding SoftUni Team Technical Trainers Software University

Code and Test vs. Test-Driven Development

Page 4: Test-Driven Development Learn the "Test First" Approach to Coding SoftUni Team Technical Trainers Software University

4

"Code First" (code and test) approach Classical approach

"Test First" approach Test-driven development (TDD)

Unit Testing Approaches

Page 5: Test-Driven Development Learn the "Test First" Approach to Coding SoftUni Team Technical Trainers Software University

The Code and Test Approach

5

Write code

Write unit test

Run and succeedTime flow

Page 6: Test-Driven Development Learn the "Test First" Approach to Coding SoftUni Team Technical Trainers Software University

The Test-Driven Development Approach

6

Page 7: Test-Driven Development Learn the "Test First" Approach to Coding SoftUni Team Technical Trainers Software University

Test-Driven Development (TDD)

7

Pick а test

Compile and fail

Write code to pass test

Write enough code to compile

Run test and fail

Create a test list

Time flow

Write test

Remove duplication

Page 8: Test-Driven Development Learn the "Test First" Approach to Coding SoftUni Team Technical Trainers Software University

8

TDD helps find design issues early Avoids reworking

Writing code to satisfy a test isa focused activity Less chance of error

Tests will be more comprehensivethan if they are written after the code

Why TDD?

Page 9: Test-Driven Development Learn the "Test First" Approach to Coding SoftUni Team Technical Trainers Software University

9

You create a 100% regression test suite The unit tests form 100% of your design specification You only need to unit test TDD is sufficient for testing TDD doesn't scale (partially true)

Your test suite takes too long to run Not all developers know how to test Everyone might not be taking a TDD approach

Myths and Misconceptions

Page 10: Test-Driven Development Learn the "Test First" Approach to Coding SoftUni Team Technical Trainers Software University

Test-Driven DevelopmentLive Demo: Tree

Page 11: Test-Driven Development Learn the "Test First" Approach to Coding SoftUni Team Technical Trainers Software University

Test-Driven DevelopmentExercises in Class

Page 12: Test-Driven Development Learn the "Test First" Approach to Coding SoftUni Team Technical Trainers Software University

12

1. Code and Test Write code, then test it

2. Test-Driven Development Write tests first

3. Reasons to use TDD Prevent some application design flaws Manage complexity more easily

Summary

Page 14: Test-Driven Development Learn the "Test First" Approach to Coding SoftUni Team Technical Trainers Software University

License

This course (slides, examples, demos, videos, homework, etc.)is licensed under the "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International" license

14

Attribution: this work may contain portions from "Fundamentals of Computer Programming with C#" book by Svetlin Nakov & Co. under CC-BY-SA license

"C# Part I" course by Telerik Academy under CC-BY-NC-SA license

Page 15: Test-Driven Development Learn the "Test First" Approach to Coding SoftUni Team Technical Trainers Software University

Free Trainings @ Software University Software University Foundation – softuni.org Software University – High-Quality Education,

Profession and Job for Software Developers softuni.bg

Software University @ Facebook facebook.com/SoftwareUniversity

Software University @ YouTube youtube.com/SoftwareUniversity

Software University Forums – forum.softuni.bg