Email (samnang.chhun@gmail.com)
Blog (http://tech.wowkhmer.com)
Rails Developer
.NET Developer
About Testing!
Test Last or DDD (Design Driven Tests)
Short development iterations
Is a design process
Based on requirement and pre-written test
cases
Tests are your first users
The goal is to produce working clean code that
fulfills requirements
If TDD hurts then you're doing it wrong
Unnecessary Codes
Unchangeable Codes
Unintelligible Code
Makes you think about required behavior.
Provides documentation.
Improves quality.
Reduces speculative code.
Less time debugging.
Confidence in change
Discover usability issues early
I don’t have time to unit test.
The client pays me to develop code, not write
unit test.
I am supporting a legacy application without
unit tests.
QA and User Acceptance Testing is far more
effective in finding bugs.
I don’t know how to unit test, or I don’t know
how to write good unit tests.
It forces you to really understand the code.
It forces you to really understand the tests
It forces you to create code that is truly reusable
and modular and testable
These forces drive you to keep your code and
your tests simple and easy to understand.
Enabling TDD
TDD Cycle
Choosing the First Test?
Green Bar Patterns
State-based vs. Interaction-based Unit Testing
NUnit         Resharper
MbUnit        TDD.NET
VSTS          Refactor Pro!
xUnit.net     Visual Studio
Moq
Rhino Mocks
create a
              failing
               test




 remove                   write
duplicatio                 just
 n clarify              enough
  intent                 to pass
RED




Refactor         Green
The simplest.
The essence.




If you need to write code that is untested,
choose a simpler test.
If the essence approach takes to much time to
implement, choose a simpler test.
Small and focused
Intention revealing
Repeatable
Independent
Have no side-effects
Description should be
• Domain-specific
• Suitable for customer comprehension
• Understandable in absence of code
Writing descriptions
• Think about behavior
• Think about the context of the behavior
• Focus on the words, not the implementation
Fake It(Til You Make It)
   Start with hardcoded results and wait until later
   tests to force them to become real.
Triangulate To Abstraction
   Make the code abstract only when you have two or
   more examples.
Obvious Implementation
   aka Don't Be Stupid
   If you really, really, honestly know the right way to
   implement it, then write it that way.
Test Driven Development
Test Driven Development

Test Driven Development

  • 2.
  • 5.
    About Testing! Test Lastor DDD (Design Driven Tests)
  • 6.
    Short development iterations Isa design process Based on requirement and pre-written test cases Tests are your first users The goal is to produce working clean code that fulfills requirements If TDD hurts then you're doing it wrong
  • 7.
  • 8.
    Makes you thinkabout required behavior. Provides documentation. Improves quality. Reduces speculative code. Less time debugging. Confidence in change Discover usability issues early
  • 9.
    I don’t havetime to unit test. The client pays me to develop code, not write unit test. I am supporting a legacy application without unit tests. QA and User Acceptance Testing is far more effective in finding bugs. I don’t know how to unit test, or I don’t know how to write good unit tests.
  • 10.
    It forces youto really understand the code. It forces you to really understand the tests It forces you to create code that is truly reusable and modular and testable These forces drive you to keep your code and your tests simple and easy to understand.
  • 11.
    Enabling TDD TDD Cycle Choosingthe First Test? Green Bar Patterns State-based vs. Interaction-based Unit Testing
  • 12.
    NUnit Resharper MbUnit TDD.NET VSTS Refactor Pro! xUnit.net Visual Studio Moq Rhino Mocks
  • 13.
    create a failing test remove write duplicatio just n clarify enough intent to pass
  • 14.
  • 16.
    The simplest. The essence. Ifyou need to write code that is untested, choose a simpler test. If the essence approach takes to much time to implement, choose a simpler test.
  • 17.
    Small and focused Intentionrevealing Repeatable Independent Have no side-effects
  • 18.
    Description should be •Domain-specific • Suitable for customer comprehension • Understandable in absence of code Writing descriptions • Think about behavior • Think about the context of the behavior • Focus on the words, not the implementation
  • 20.
    Fake It(Til YouMake It) Start with hardcoded results and wait until later tests to force them to become real. Triangulate To Abstraction Make the code abstract only when you have two or more examples. Obvious Implementation aka Don't Be Stupid If you really, really, honestly know the right way to implement it, then write it that way.