Test Driven Development
-
Upload
sachithra-gayan -
Category
Software
-
view
443 -
download
0
Transcript of Test Driven Development
Content What is TTD?Unit Test & RefactoringGot Bugs?Tenets of TTD.Benifits of TDD.Advantages & Disadvantages of TDD.
What is TDD? It is just about writing the test before the
program.It’s a testing technique as well as a design
Technique.In the end, there is no code without a test.The developer can tell at any time.Unit Tests and Refactoring are the tools of
TDD.
Unit Tests Easy to read & understand.Execute very quickly.Independent of execution order.Test specific aspects of a functionality.Tests a very small section of code isolation.Rapid feedback.
Refactoring Take existing code & change it more efficient.Change the internal structure of code without
changing its external behavior.Ex :-•ab + ac = a(b+c)
Same result, but the expression is simplified.
Start Write a test for new capability
Compile
Fix compile errors
Run the testRun the testAnd see it failAnd see it fail
Write the code
Run the testRun the testAnd see it passAnd see it pass
RefactorRefactor as needed as needed
Red/Green/Refactor
Got bugs? Go after defect. Writing a test to expose it..Write code needed to fix it.Refactor.Repeat.Measure the result.
Tenets of TDD Split work into small requirements. Always start by writing a test.Eliminate duplication.Write the simple code to pass the test.
What can test by TDD? Valid inputs. Invalid inputs.Errors, exceptions and events.Boundary conditions.
Benefits for Developers Much less debug time. Code proven to meet requirement.Test become Safety Net.Process consulting.Project mentoring.Eliminate bugs.
Benefits for Business Shorter development cycles. Near zero defect.Test become an asset.Test are documentation.Competitive advantage.
Gets running code very quickly.Development in small steps. This will make
debugging easier since we will have small code chunks to debug.
Produce fully testable code.Design to the specification, don’t over
engineer.
Advantages
“Write test, write code to pass test, repeat” loop is overly strict.
Setup requires some what complex wiring.Causes people to take paths they wouldn’t
otherwise.
Disadvantages
References “Test-Driven Development By Example”; Kent
Beck;2003.“Refactoring, Improving The Design Of Existing
Code”; Martin Fowler;1999. “Patterns Of Enterprise Application
Architecture”; Martin Fowler;2003.