5. 5
Should have bought a snow blower
March 17, 2011 – Developer Track
6. 6
1. Reasons behind testing and why you should care
2. Development and testing with VS-2010
3. Something-Driven styles and contrasts
4. Types of testing
5. Coded UI testing – demo
6. Database Unit testing - demo
7. Continuous Integration Practices
8. Unit test & TeamCity - demo
9. Conclusion & References
March 17, 2011 – Developer Track
7. 7
Bugs are expensive – over $59 billion/year
On average, 100 errors per 1,000 lines of code
Cancelled and over-ran projects combined cost
around $88 billion in 2009
A few examples…
March 17, 2011 – Developer Track
8. 8
Code Re-use
Conversion from 64-bit to 16-bit
signed int caused overflow,
exception handling was disabled
for some other reason –
COST > $370 million (‘96 dollars)
March 17, 2011 – Developer Track
9. 9
Crossed international dateline
the first time on the way to
Japan, computers crashed losing
all navigation and
communication systems.
Luckily with clear weather, it
followed tankers back to Hawaii
March 17, 2011 – Developer Track
10. 10
Failed to wake up users during Daylight Savings Time change
March 17, 2011 – Developer Track
11. 11
Writing tests first help write better code
Process of writing a test first helps to see when a
design is too rigid or unfocused
Testing is no longer just about keeping defects from the
users; instead it is about helping the team understand the
features users need and deliver them reliably and predictably
March 17, 2011 – Developer Track
12. 12
Repeated cycles of activity Each cycle adds new features
and team gets feedback
Each cycle deploys work to some kind
of environment
Every deploy, team has an opportunity to
check the assumptions against reality
Without deployment, the feedback is
not complete
March 17, 2011 – Developer Track
14. 14
Incremental development
Iterative development
builds a system feature,
progressively refines the
instead of building layers and
implementation of features
components and integrating
in response to feedback
them at the end.
until they are good enough.
Each feature is implemented
In other words, reacting to
as an end-to-end “slice”.
the “anticipating to the
System is always integrated
unanticipated”
and ready for deployment
March 17, 2011 – Developer Track
15. 15
Release
Test
Development
March 17, 2011 – Developer Track
18. 18
The catch is that few developers enjoy testing their code.
Many see writing automated tests is seen as not “real” work
compared to adding features. They find it boring.
It takes a different mind set and takes time to learn and master.
TDD makes coding a design activity. Use tests to clarify ideas
about what the code should do.
Having tests during development process can build up a safety
net of automated regression tests.
These tests give confidence to make changes.
All of a sudden, you are doing “Red – Green – Refactor”
“… you have nothing to lose but your bugs”
March 17, 2011 – Developer Track
19. 19
Evolution of TDD Test method names should be sentences
Writing tests that matter “Given, When, Then”
Concept of executable specifications
March 17, 2011 – Developer Track
20. 20
Start feature with an acceptance test
Develop from the inputs & outputs
MSDN Article: http://msdn.microsoft.com/en-us/magazine/gg490346.aspx
March 17, 2011 – Developer Track
21. 21
Unit / Integration / Acceptance Tests
Database Unit Test
Coded UI Tests
Web Performance and Load Tests
March 17, 2011 – Developer Track
23. 23
SP1 is available
Help viewer updates
Silverlight 4 support
Unit testing for .NET 3.5
IIS Express support
SQL Server CE Support
Razor support “Pimp my IDE” check out
http://studiostyl.es
Feature Pack 2
Code visualization and modeling
Improved Coded UI Testing
March 17, 2011 – Developer Track
24. 24
SQL Server 2008
http://blogs.msdn.com/b/atverma/archive/2010/07/28/how-to-unit-test-sql-server-
2008-database-using-visual-studio-2010.aspx
March 17, 2011 – Developer Track
25. 25
A unit test is a piece
of code that invokes
another piece of code,
Is Automated and repeatable
resides in another
assembly Is Easy to implement
Should remain for future use
Is run by anyone
Should run with a push of a button
Runs quickly
SUT : System Under Test
(CUT : Code under Test)
: Class under Test)
March 17, 2011 – Developer Track
27. 27
Development &
Architecture Lab Management Test TFS
Database
•Architecture Explorer •Historical debugging •Multi-tier •Test planning •Work item hierarchy
•Layer Diagram •Test impact analysis environment creation •Test case & link types
•Use case designer •Improved code and management management •Improved Agile
•Activity designer analysis •Automated •Test prioritization template
•Improved profiling deployment •Run management & •MOSS & WSS
•Component diagram
(incl. multi-tier) •Easily manage reporting dashboards
•Logical class designer
•Database extensibility machine pools •Project quality •Simplified reporting
•Sequence diagram
•Network fencing reports •Improved support for
•Modeling project
•Checkpoints •Manual test parallel development
system
execution •Rollback
•UML Model Explorer
•Diagnostic recording •Build queuing and
•Architecture
(environment, video, pooling
validation during
etc.) •Gated check-in
build
•UI Automation •Simplified setup
recording •Scale out of web and
•Coded UI tests data tiers
•Admin console
•Project
move/archive/restore
March 17, 2011 – Developer Track
28. 28
Maintain a Single Source Repository
Automate the Build
Make Your Build Self-Testing
Keep the Build Fast
Everyone can see what's happening
Automate Deployment
http://martinfowler.com/articles/continuousIntegration.html
March 17, 2011 – Developer Track
34. 34
Goal is to ship to “less” buggy, rigid
software. TDD and BDD will help.
Just keep an open mind!
VS-2010 has many other features on various testing
mechanisms. Take the time to learn and master them.
Don’t hesitate looking at other platforms for ideas.
Continuous Integration is more than “nice to
have” any more. If you are serious about what
you are doing, you should have it.
March 17, 2011 – Developer Track