Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
@LaylaCodesIt
@LaylaCodesIt
@LaylaCodesIt
MICROSOFTMVP


GITHUBSTAR


MK.NETORGANISER


C#LOVER


DEVELOPERADVOCATE@VMWARE


LAYLAPORTER
@LaylaCodesIt
WHYTDDANDTHETERMINATOR?
@LaylaCodesIt
TDDSUCCESSES
•Acceptance Criteria


•Focus


•Interfaces


•Asynchronous development


•Cleaner code


•Safe...
@LaylaCodesIt
BACKTOTHETERMINATOR
@LaylaCodesIt
THEPROCESS
@LaylaCodesIt
GATHERTHEREQUIREMENTS
@LaylaCodesIt
@LaylaCodesIt
Terminator Requirements
Scan subjects and determine if they
require further investigation
Investigate subjec...
@LaylaCodesIt
Scan subjects and determine if
they require further investigation
@LaylaCodesIt
STARTWITHFAILINGTESTS
@LaylaCodesIt
When you write tests after coding you
may be writing them to fit your code
and not your requirements
@LaylaCodesIt
RED/GREENREFACTORPATTERN
• Write a failing test


• Write enough code to get the test to pass


• Refactor!
@LaylaCodesIt
OVERTOCODE
@LaylaCodesIt
REFACTOR!
@LaylaCodesIt
public
 
bool
 
InvestigateFurther(ISubject
 
subject)


{


 
 
 


 
 
 
 
if
 
(subject.SubjectName.ToLow...
@LaylaCodesIt
public
 
bool
 
InvestigateFurther(ISubject
 
subject)


{


 
 
 
 
switch
 
(subject.SubjectName.ToLower()...
public
 
bool
 
InvestigateFurther(ISubject
 
subject)


{


 
 
 
 
switch
 
(subject.SubjectName.ToLower())


 
 
 
 
{
...
public
 
bool
 
InvestigateFurther(ISubject
 
subject)


{


 
 
 
 
switch
 
(subject.SubjectName.ToLower())


 
 
 
 
{
...
@LaylaCodesIt
WITHGOODPRACTICES,CODEMANAGEMENTBECOMESINFINITELYEASIER
@LaylaCodesIt
TDDFAILURES
•Underestimating the learning curve


•Confusing TDD with unit testing


•Thinking TDD is enough...
@LaylaCodesIt
IMPLEMENTATIONWITHINYOURORGANIZATION
•Can be controversial and is a significant culture change


•Initial dr...
@LaylaCodesIt
IFYOUTAKEONETHINGAWAYFROMTHISTALK...
@LaylaCodesIt
[Test]


public void


TerminatorShould_Determine_ToInvestigateFurther


(ISubject subject)


{


var subjec...
@LaylaCodesIt
[Test]


public void


TerminatorShould_Determine_ToInvestigateFurther


(ISubject subject)


{


var subjec...
@LaylaCodesIt
[Test]


public void


TerminatorShould_Determine_ToInvestigateFurther


(ISubject subject)


{


var subjec...
@LaylaCodesIt
Twitter:@LaylaCodesIt


GitHub:Layla-P


Email:laylap@vmware.com
Repo:http://bit.ly/tdd-terminator


Deck:ht...
You’ve finished this document.
Download and read it offline.
Upcoming SlideShare
What to Upload to SlideShare
Next
Upcoming SlideShare
What to Upload to SlideShare
Next
Download to read offline and view in fullscreen.

Share

TDD and the Terminator: An Introduction to Test-Driven Development

Download to read offline

SpringOne 2021
Session Title: TDD and the Terminator: An Introduction to Test-Driven Development
Speaker: Layla Porter, Developer Advocate, .NET communities at VMware

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all
  • Be the first to like this

TDD and the Terminator: An Introduction to Test-Driven Development

  1. 1. @LaylaCodesIt
  2. 2. @LaylaCodesIt
  3. 3. @LaylaCodesIt MICROSOFTMVP GITHUBSTAR MK.NETORGANISER C#LOVER DEVELOPERADVOCATE@VMWARE LAYLAPORTER
  4. 4. @LaylaCodesIt WHYTDDANDTHETERMINATOR?
  5. 5. @LaylaCodesIt TDDSUCCESSES •Acceptance Criteria •Focus •Interfaces •Asynchronous development •Cleaner code •Safe refactoring •Fewer bugs •Increasing returns •Living documentation
  6. 6. @LaylaCodesIt BACKTOTHETERMINATOR
  7. 7. @LaylaCodesIt THEPROCESS
  8. 8. @LaylaCodesIt GATHERTHEREQUIREMENTS
  9. 9. @LaylaCodesIt
  10. 10. @LaylaCodesIt Terminator Requirements Scan subjects and determine if they require further investigation Investigate subjects of interest and determine if they are the target - TERMINATE!
  11. 11. @LaylaCodesIt Scan subjects and determine if they require further investigation
  12. 12. @LaylaCodesIt STARTWITHFAILINGTESTS
  13. 13. @LaylaCodesIt When you write tests after coding you may be writing them to fit your code and not your requirements
  14. 14. @LaylaCodesIt RED/GREENREFACTORPATTERN • Write a failing test • Write enough code to get the test to pass • Refactor!
  15. 15. @LaylaCodesIt OVERTOCODE
  16. 16. @LaylaCodesIt REFACTOR!
  17. 17. @LaylaCodesIt public   bool   InvestigateFurther(ISubject   subject) {               if   (subject.SubjectName.ToLower()   = =   "woman")         {                 return   true;         }                         if   (subject.SubjectName.ToLower()   = =   "girl")         {                 return   true;         }                         if   (subject.SubjectName.ToLower()   = =   "man")         {                 return   true;         }                         if   (subject.SubjectName.ToLower()   = =   "boy")         {                 return   true;         }                         return   false; }
  18. 18. @LaylaCodesIt public   bool   InvestigateFurther(ISubject   subject) {         switch   (subject.SubjectName.ToLower())         {                 case   "woman":                 case   "girl":                 case   "man":                 case   "boy":                         return   true;                 default:                         return   false;         } } public
  19. 19. public   bool   InvestigateFurther(ISubject   subject) {         switch   (subject.SubjectName.ToLower())         {                 case   "woman":                 case   "girl":                 case   "man":                 case   "boy":                         return   true;                 default:                         return   false;         } } [TestCase("woman")] [TestCase("girl")] [TestCase("man")] [TestCase("boy")] public   void   TerminatorShould_Determine_ToInvestigate Further (string   subjectName) {         var   subject   =   new   Subject   {SubjectName   =   subject Name};         var   result   =   _sut.InvestigateFurther(subject);         result.Should().BeTrue(); } [Test]
  20. 20. public   bool   InvestigateFurther(ISubject   subject) {         switch   (subject.SubjectName.ToLower())         {                 case   "woman":                 case   "girl":                 case   "man":                 case   "boy":                         return   true;                 default:                         return   false;         } } [TestCase("woman")] public   void   TerminatorShould_DetermineNot_ToInvestigateFurther() {     var   subject   =   new   Subject   {SubjectName   =   "T1000"};     var   result   =   _sut.InvestigateFurther(subject);     result.Should().BeFalse(); }
  21. 21. @LaylaCodesIt WITHGOODPRACTICES,CODEMANAGEMENTBECOMESINFINITELYEASIER
  22. 22. @LaylaCodesIt TDDFAILURES •Underestimating the learning curve •Confusing TDD with unit testing •Thinking TDD is enough testing •Not starting with failing tests •Not refactoring enough •Not actually doing TDD!
  23. 23. @LaylaCodesIt IMPLEMENTATIONWITHINYOURORGANIZATION •Can be controversial and is a significant culture change •Initial drop in productivity can be disconcerting •Productivity will go up and reworks reduced •Increased understanding of requirements and their acceptance criteria
  24. 24. @LaylaCodesIt IFYOUTAKEONETHINGAWAYFROMTHISTALK...
  25. 25. @LaylaCodesIt [Test] public void TerminatorShould_Determine_ToInvestigateFurther (ISubject subject) { var subject = new Subject{SubjectName = "woman"}; var result = _sut.InfestigateFurther(subject); result.Should().BeTrue(); }
  26. 26. @LaylaCodesIt [Test] public void TerminatorShould_Determine_ToInvestigateFurther (ISubject subject) { var subject = new Subject{SubjectName = "woman"}; var result = _sut.InfestigateFurther(subject); result.Should().BeTrue(); } public bool _sut.InvestigateFurther(ISubject subject) { return true; }
  27. 27. @LaylaCodesIt [Test] public void TerminatorShould_Determine_ToInvestigateFurther (ISubject subject) { var subject = new Subject{SubjectName = "woman"}; var result = _sut.InfestigateFurther(subject); result.Should().BeTrue(); } public bool _sut.InvestigateFurther(ISubject subject) { return true; } Write the least amount of code to get your test to pass. Return true!
  28. 28. @LaylaCodesIt Twitter:@LaylaCodesIt GitHub:Layla-P Email:laylap@vmware.com Repo:http://bit.ly/tdd-terminator Deck:http://bit.ly/tdd-deck Twitch:twitch.tv/LaylaCodesIt Yaks:https://bit.ly/shaving-a-yak

SpringOne 2021 Session Title: TDD and the Terminator: An Introduction to Test-Driven Development Speaker: Layla Porter, Developer Advocate, .NET communities at VMware

Views

Total views

111

On Slideshare

0

From embeds

0

Number of embeds

3

Actions

Downloads

8

Shares

0

Comments

0

Likes

0

×