Upload
gil-zilberfeld
View
2.546
Download
2
Tags:
Embed Size (px)
DESCRIPTION
Breaking down the unit test writing process into tiny bits. What to think about, what to focus on, and how are tools affect what we do.
Citation preview
@gil_zilberfeld
SELA DEVELOPER PRACTICEMay 5-9, 2013
Gil Zilberfeld
7 Steps for writing your first test
@gil_zilberfeld
Who am I?
www.typemock.com
typemock.com/blog
@typemock
www.gilzilberfeld.com
@gil_zilberfeld
@gil_zilberfeld
Step 0: Prepare
• Know your tools
• Evaluate the risk
• Choose your partner
@gil_zilberfeld
Step 1: What to test
• What you’re working on• Bug or feature?• Logic• Read it first• What not to test:• Multithreading• Stored procedures• UI
@gil_zilberfeld
Step 2: Get ready
• Pick organization strategy• Create test projects• Remove fluff• VS I’m looking at you
@gil_zilberfeld
Step 3: Pick a scenario
• Scenario consists of • Context• Logic• Success criteria
• Pick the simplest scenario• Say it!• Name it!• Assert it!
:// . . /http erpstore codeplex com
@gil_zilberfeld
Step 4: Identify dependencies• Read the code• Constructor parameters• Fields• Statics• Global state
• Mocking strategy• None• Where to mock• How to mock
@gil_zilberfeld
Step 5: Simplify design
• Refactor with tools: VS, R#, DevExpress• Close down regions you’re not going to cover• Rename fields• Extract methods
• Manual refactoring works too• …but more risky
@gil_zilberfeld
Step 6: Here we go!
• Arrange• Run• Fail• Arrange more• Run• …..• Success!
@gil_zilberfeld
Step 7: Move on!
• Pick the next scenario• Say it• Name it• Assert it
• Mutate the test setup• Arrange• Run • …• Win!
@gil_zilberfeld
Congratulations!
• This is just the beginning• Lifetime improvement• Picking scenarios• Naming• Mocking• Refactoring
@gil_zilberfeld
Would you like to know more?
www.typemock.com
typemock.com/blog
@typemock
www.gilzilberfeld.com
@gil_zilberfeld
@gil_zilberfeld
Thank You