2. What is Test Driven Development(TDD)?
Test-Driven Development (TDD) is a technique for building software that
guides software development by writing tests
Write test first,then write out logic
«Code without tests is bad code» Michael C. Feathers
How can you have a test if there is nothing to test?
5. Effective Unit Tests Are F.I.R.S.T
Fast
to run them
frequently
Independent
of each other
Repeatable
in any
environment
Self-Validating
and so either
passing or failing
Timely
written before the
production code
7. Popular Unit Testing Frameworks for .NET
MSTest
Comes with Visual Studio
https://github.com/Micro
soft/testfx
NUnit
Initially ported from JUnit
Current production
release, version 3, has
been completely rewritten
https://github.com/nunit/
nunit
xUnit
Written by the original
invertor of NUnit v2
https://xunit.github.io/
8. Demo 1
Requirement:
“Create a library method that takes in a
sentence and a single character as
parameters. The method should return a
number that indicates how many times
the character appears in the sentence.”
9. What is Mocking?
Mock Objects
Fake
Stub
Mock
Popular mocking frameworks for .Net:
Moq
Nsubstitute
NMock3
Rhino Mocks
FakeItEasy
JustMock
12. TDD and Legacy Code
Legacy code is
«Code without tests»
«Code you're afraid to change»
TDD is difficult to use on legacy codebases
The first step is admitting you have a problem
13. Code Coverage
If you've been following TDD, then there is no code that was ever written
without being required by a test, so you should always be near 100%
coverage.
Visual Studio Code Coverage Tool: