automated unit testing in silverlight for windows phone 7
Post on 10-May-2015
4.081 Views
Preview:
DESCRIPTION
TRANSCRIPT
Automated Unit Testing with Silverlight for Windows Phone 7
Jacinto Limjap, Jr.Microsoft MVP for C#
Senior Applications Developer, FBM e-Services
Agenda
• Automated unit testing and Test Driven Development
• MVVM – an overview• Putting it all together using Silverlight for
Windows Phone 7
Any mobile developers in the house?
What do you use in terms of frameworks/patterns/unit testing?
AUTOMATED UNIT TESTING & TDDAn introduction
What is Test Driven Development?
• Using unit tests to design software• Allows change in code without fear of
(inadvertently ) changing functionality• Produces loosely coupled objects and
methods with single responsibilities
What is Test Driven Development?
• Unit tests are just side effects: main point is DESIGN
• Write tests first, code later (?!)
What is Test Driven Development NOT?
• Substitute for QA testing• Necessarily means successful project• Silver bullet
TDD Mindset
Writing Tests
• Think about how you want to express your code and intentions
• Think about inputs, and intended output• Separate small, isolated areas of functionality
Issues
• Unit tests should come BEFORE code• Unit tests should NOT depend on presence or
absence or external dependencies (e.g., storage, database, internet connection)
• How to solve this: Mocks, stubs and fakes
Do we really have to do test first?
MVVMThe Model View ViewModel Pattern
Model-View-ViewModel
• Introduced in 2005 by John Gossman• Originally designed for Windows Presentation
Foundation (WPF) applications• Designed in response to attempts to use
Model-View-Controller (MVC) in WPF
Model-View-ViewModel
• Model – class or data representation of object you are using within your application
• View – the part of your application representing the user interface
• ViewModel – class or data representation of an object or combination of objects, as seen in the View
Model-View-ViewModel
View(XAML)
View(XAML)
View ModelView Model
ModelModel
Data BindingData Binding
So why is MVVM important?
DEMOUnit testing on Silverlight for Windows Phone 7
Discussion
• http://dotnet.kapenilattex.com• http://twitter.com/LaTtEX• http://facebook.com/LaTtEX
References• Introduction to Model/View/ViewModel pattern for building WPF apps http://
blogs.msdn.com/b/johngossman/archive/2005/10/08/478683.aspx• Silverlight Patterns: Model-View-ViewModel in Silverlight 2 apps http://
msdn.microsoft.com/en-us/magazine/dd458800.aspx• Model-View-ViewModel (MVVM) Explained http://
csharperimage.jeremylikness.com/2010/04/model-view-viewmodel-mvvm-explained.html• Introduction to Test Driven Development http://dotnet.kapenilattex.com/?p=201• Windows Phone 7 Tutorials http://compiledexperience.com/windows-phone-7• Updated Silverlight Unit Testing Framework bits for Windows Phone and Silverlight 3
http://www.jeff.wilcox.name/2010/05/sl3-utf-bits/• Steps to run the Windows Phone 7 Unit Test Framework successfully http://
codingsolutions.blogspot.com/2010/03/steps-to-run-windows-phone-7-unit-test.html• TDD Kata for Windows Phone 7
http://github.com/dgadd/TDD_Kata_For_MVVM_on_Win_Phone_7• Migrating Apps from Windows Phone April CTP Refresh to Beta Build
http://blogs.msdn.com/b/jaimer/archive/2010/06/28/migrating-apps-from-windows-phone-ctps-to-the-beta-build.aspx?wa=wsignin1.0
top related