We think you have liked this presentation. If you wish to download it, please recommend it to your friends in any social system. Share buttons are a little bit lower. Thank you!
Presentation is loading. Please wait.
Published bySade Beaver
Modified over 2 years ago
Writing Unit Tests with Microsoft Fakes Copyright © Intertech, Inc Slide 1 Writing Unit Tests with Microsoft Fakes A Consulting Division Presentation Month Date, 2006 © All Rights Reserved Tim Star /
Writing Unit Tests with Microsoft Fakes Copyright © Intertech, Inc Slide 2 Experience Principal Consultant /.Net Architect Visual Studio ALM Ranger – 5 years MS Testing tools consulting and training Load testing Development Manager MCPD Enterprise App Development 3.5/4.0 Framework MCTS WPF/TFS MCP – VS ALM and Testing with MTM MCT 4 X Microsoft MVP
Writing Unit Tests with Microsoft Fakes Copyright © Intertech, Inc Slide 3 Agenda Unit testing Why Design Principles for testability What is the Fakes framework How does it help How does it work Stubs Shims How Do I choose Resources Demo
Writing Unit Tests with Microsoft Fakes Copyright © Intertech, Inc Slide 4 Why Unit test Make sure the code works Refactor with confidence Support emerging design Find errors and design flaws early - $ Get a quick understanding of the quality of code
Writing Unit Tests with Microsoft Fakes Copyright © Intertech, Inc Slide 5 Design Principles for testability Single responsibility principle (SRP) Open Closed Principle (OCP) Liskov Substitution Principle (LSP) Interface Segregation Principle (ISP) Dependency Inversion Principle (DIP) Dont Repeat Yourself (DRY) You Arent Going to Need It (YAGNI) Great resource: Agile Principles, Patterns, and Practices in C#
Writing Unit Tests with Microsoft Fakes Copyright © Intertech, Inc Slide 6 What is the Microsoft Fakes Framework? Microsoft Fakes is a framework that enables us to isolate the code we are testing by replacing dependencies of our code with stubs or shims. The Fakes Framework in Visual Studio 2012 is the next generation of Moles & Stubs. (Read: migrate not upgrade) Available in VS 2012 Ultimate or VS 2012 Premium beginning with Update 2 Works with.Net framework 2.0 and Above
Writing Unit Tests with Microsoft Fakes Copyright © Intertech, Inc Slide 7 How does the Fakes framework Help Allows us to quickly implement doubles to support testing in isolation Allows us to decouple from slow running dependencies like DB, file system, message system. Decoupling allows us to write order independent unit tests Stage data in test methods, not in a DB. One unit test failure will not cause a chain reaction No need to reset a database to a golden state. Allows us to intercept calls to dependencies we do not control.
Writing Unit Tests with Microsoft Fakes Copyright © Intertech, Inc Slide 8 Stubs and Shims Stubs – Code generator that generates classes that implement interfaces. Uses delegates so our tests supply the implementation. Shims – Modifies code at runtime to intercept calls to dependencies. (Read: slower) Accepts delegates so tests can provide alternate implementation.
Writing Unit Tests with Microsoft Fakes Copyright © Intertech, Inc Slide 9 Choosing between stubs and shims Performance. Shims run slower because they rewrite your code at run time. Stubs do not have this performance overhead and are as fast as virtual methods can go. Static methods, sealed types. You can only use stubs to implement interfaces. Therefore, stub types cannot be used for static methods, non-virtual methods, sealed virtual methods, methods in sealed types, and so on. Internal types. Both stubs and shims can be used with internal types that are made accessible by using the assembly attribute InternalsVisibleToAttribute. Private methods. Shims can replace calls to private methods if all the types on the method signature are visible. Stubs can only replace visible methods. Interfaces and abstract methods. Stubs provide implementations of interfaces and abstract methods that can be used in testing. Shims cant instrument interfaces and abstract methods, because they dont have method bodies.
Writing Unit Tests with Microsoft Fakes Copyright © Intertech, Inc Slide 10 Resources MSDN - us/library/hh aspxhttp://msdn.microsoft.com/en- us/library/hh aspx 2 Day Unit Testing Course - Visual-Studio/Unit-Testing/Unit-Testing-in- Visual-Studio-2012#axzz2a6ibYDAM Visual-Studio/Unit-Testing/Unit-Testing-in- Visual-Studio-2012#axzz2a6ibYDAM ALM Rangers eBook - eases/view/ eases/view/ /visual-studio-11-fakes-part-1/http://www.peterprovost.org/blog/2012/04/1 5/visual-studio-11-fakes-part-1/
Copyright © 2005 Finetix LLC All Rights Reserved Test Driven Development and Mock Objects DevSession July Chris Donnan-
ACT! “Web” Plugins ACC Webinar (Part 1of 2) Brian Mowka and Jamie Aurand December 2010.
(Advanced) Web Application Development Test Driven Development with Ruby and Rails Bruce Scharlau, University of Aberdeen, 2013.
Black marble the strategic IT asset for your organisation DEVELOPMENT LIFE CYCLE USING VISUAL STUDIO TEAM EDITION FOR DB PROFESSIONALS Richard Fennell.
Development Life Cycle using Visual Studio Team Edition for DB Professionals Richard Fennell Engineering Director SQLBits II Birmingham 1 st March 2008.
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. The OWASP.
Using VB with MS Applications R. Juhl, Delta College.
Prism is 100% Resume Compliant! Trendy design patterns! Test-Driven Development Loosely Coupled Blend-able UIs Interface-based Programming Dependency Injection.
Copyright © 2005 Finetix LLC All Rights Reserved 0 Spring Framework Developer Session Chris Donnan & Solomon Duskis The Peer Frameworks Series -.Net and.
Clark County & the Web Application Development Framework.
Unit Testing in SQL Richard Fennell Engineering Director SqlBits 6 th October 2007.
Black marble the strategic IT asset for your organisation MAKING THE SQL DEVELOPER ONE OF THE FAMILY WITH VISUAL STUDIO TEAM SYSTEM Richard Fennell Engineering.
Neelesh Kamkolkar Sr. Product Manager/Planner | Microsoft
Training and consulting in Java, EJB, J2EE, and XML / Mastering.
Object Oriented Design Principles Arnon Rotem-Gal-Oz Product Line Architect.
A Taste of Visual Studio 2005 David Grey. Introduction In this session we will introduce Visual Studio 2005 and its features and examine those features.
A Practical Guide To Unit Testing John E. Boal TestDrivenDeveloper.com.
Jet Enterprise Installation Instructions for Jet Partners V
© 2010 VMware Inc. All rights reserved One does not simply start a career in IT: Launch yours with an Alexandar Bonev, Manager QE.
1 Computer Systems & Architecture Lesson 3 5. Designing the Architecture.
Of. and a to the in is you that it at be.
VWF313: Designing and Building Workflow Solutions for SharePoint 2007 Tim Huckaby CEO, InterKnowlogy Microsoft RD & MVP.
Summary To fully leverage cloud computing we need to understand both the strengths and weaknesses of the cloud. In this talk, we will demonstrate how the.
Todd Kitta Business Data Catalog (BDC) Basics Web Parts BDC Development Search API Demo.
A load testing solution for web applications This presentation should be viewed as a Slide Show. Choose “Slide Show” from the PowerPoint menu and click.
Źródło:http://msdn.microsoft.com/en-us/library/ms aspxhttp://msdn.microsoft.com/en-us/library/ms aspx.
“Try not. Do, or do not. There is no try.” - Yoda Yoda finally admits he does not understand exception handling...
1 19-Jan-14 © Copyright: City Boy Salary : Simon Powers : 2014 Brown Bag – Behaviour Driven Development with Specflow Brown Bag – Behaviour Driven Development.
Faith Allington Program Manager Microsoft Corporation WSV322.
© 2016 SlidePlayer.com Inc. All rights reserved.