Unit Testing Beyond Mock Objects Sven Rosvall ACCU 2014.

Slides:



Advertisements
Similar presentations
.NET 4.0 Code Contacts .NET 4.0 Code Contracts About Me James Newton-King Developer at Intergen Blog:
Advertisements

The map and reduce functions in MapReduce are easy to test in isolation, which is a consequence of their functional style. For known inputs, they produce.
Writing Unit Tests with Microsoft Fakes Copyright © Intertech, Inc Slide 1 Writing Unit Tests with Microsoft Fakes.
pa 1 Porting BETA to ROTOR ROTOR Projects Presentation Day, June by Peter Andersen.
Visual Studio Extensibility, DSL Tools and T4 Code Generation Peter Goodman.
INTERFACES IN JAVA 1.Java Does not support Multiple Inheritance directly. Multiple inheritance can be achieved in java by the use of interfaces. 2.We need.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Advanced Programming in Java
Sadegh Aliakbary Sharif University of Technology Fall 2010.
2010 Microsoft Student Partners. T OPICS - User Interface and Editor Improvements - New windows: Call Hierarchy, Navigate To - IntelliSense - Generate.
1 Programming Languages b Each type of CPU has its own specific machine language b But, writing programs in machine languages is cumbersome (too detailed)
Mockito Introduction What is Mockito? – Mockito is mocking frame work for Java Objects.
Protection of Agent Teamwork By Jeremy Hall. Agent Teamwork Overview ● Mobile agent framework  AgentTeamwork 2 is a mobile-agent based middleware system.
Platforms and tools for Web Services and Mobile Applications Introduction to C# Bent Thomsen Aalborg University 3rd and 4th of June 2004.
Mock Objects. What are Mock Objects  Any dummy object that stands in for a real object that is not available, or is difficult to use in a test case 
Programmer Testing Testing all things Java using JUnit and extensions.
Separation of Concerns Tao Xie Peking University, China North Carolina State University, USA In collaboration with Nikolai Tillmann, Peli de Halleux, Wolfram.
Agile Developers Go Testing Part II Darcy Alexei November 2010.
DB Libraries: An Alternative to DBMS By Matt Stegman November 22, 2005.
Setting up for TTD in Visual Studio 2012 Project | Manage NuGet Packages Select the online tab Search for Nunit Select the Nunit package Follow these instructions.
Capture-Replay Mocks Scandinavian Developer Conference 4 th April 2011 Geoff Bache.
Abstract Factory Design Pattern making abstract things.
Programming Pillars Introduction to Object- Oriented Programming.
Test Driven Development Arrange, Act, Assert… Awesome Jason Offutt Software Engineer Central Christian Church
DEV411 Testing Un-Testable Code with Visual Studio 2012 Fakes Peter Provost Sr. Program Manager Lead Microsoft Corporation DEV411.
Automated UI testing of Swing based applications Tomas Krecmer Barclays 27. February 2012.
Alcatel-Lucent CDC Workshop, Coaching & Knowledge Transfer Architecture.
Software Engineering Design Patterns. Singleton Single instance of class Constructor is private static final Class instance constructed when application.
AP Computer Science A – Healdsburg High School 1 Interfaces, Abstract Classes and the DanceStudio - Similarities and Differences between Abstact Classes.
Using Mock Objects with Test Driven Development Justin Kohlhepp
Module 10: Inheritance in C#. Overview Deriving Classes Implementing Methods Using Sealed Classes Using Interfaces Using Abstract Classes.
Mock objects.
Zero to Hero: Untested to Tested with Visual Studio Fakes Benjamin
Abstract Classes and Interfaces Chapter 9 CSCI 1302.
Testing Azure Applications with Visual Studio 2010 Abhishek Agrawal Senior Program Manager Visual Studio Microsoft Corporation
Test Stubs... getting the world under control. TDD of State Pattern To implement GammaTown requirements I CS, AUHenrik Bærbak Christensen2.
Mock Me If You Can An Introduction to the Mocking Framework Mockito Symposium on Software Performance 2014 Christian Wulf ― Software Engineering.
European Organization for Nuclear Research Geneva LHCb - JGaudi.
Know Your Java. Java is special Java source code Byte code/ native code Object code on windows Object code on Dos Object code on Lynux.
(c) University of Washington05-1 CSC 143 Java Abstract Classes and Frameworks Reading: Ch. 11.
C++ General Characteristics: - Mixed typing system - Constructors and destructors - Elaborate access controls to class entities.
M ICROSOFT.NET Kyle Adamski 10/15/2012. Road Map What is.NET? Common Language Runtime (CLR) Language Integrate Queries (LINQ).NET Pros.NET Cons Sources.
Understanding Dependency Injection… and those pesky containers Miguel A. Castro Architect -
Automated Testing for Dynamics CRM
Test Isolation and Mocking Technion – Institute of Technology Author: Gal Lalouche © 1 Author: Gal Lalouche - Technion 2016 ©
Testing PA165 Dec 9, 2014 Petr Adámek, Tomáš Pitner.
Ognjen Bajić Ana Roje Ivančić Ekobit Efficient Application Testing.
Ukázková aplikace je ke stažení na wug
Advanced Programming in Java
Advanced Programming in Java
Axel Faust Senior IT-Consultant / Software Architect PRODYNA AG
Mocking Tool for easier unit testing
Classes and Inheritance
Eddie Jaquith Alexis Jarvis
Test Isolation and Mocking
Internet and Java Foundations, Programming and Practice
EE 422C Java Reflection re·flec·tion rəˈflekSH(ə)n/ noun
Code Contracts and Pex Peli de Halleux, Nikolai Tillmann
Interface.
Unit Testing with xUnit.net-Part-2
Interfaces.
ms vısual studıo 2008-Introductıon TUTORIAL
DEV411 Testing Un-Testable Code with Visual Studio 2012 Fakes
Advanced Programming in Java
Advanced Programming in Java
Zero to Hero: Untested to Tested with Visual Studio Fakes
2/24/2019 © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks.
Designing For Testability
ADO.NET Entity Framework
.Net for Test and Measurement
Presentation transcript:

Unit Testing Beyond Mock Objects Sven Rosvall ACCU 2014

Agenda Traditional unit testing and mocking. Design to interfaces. 3rd party libraries without interfaces? Use mockable wrappers, for example TimeProvider. My own example where 3rd party library returns objects with no public constructors. New generation mocking frameworks

Example: Get current time

Example2: Manage VMs

Mocking Frameworks Traditional mock frameworksNew mock frameworks Use reflectionInstrument byte code Limited to virtual methods. Mocked classes must have interfaces or abstract classes Mock static, final/sealed classes and static, final methods. Requires good design “programming against interfaces” Mocking for legacy libraries. MoQ, Rhino MocksMicrosoft Fakes, Typemock Isolator EasyMock, JMock, MockitoPowerMock, JMockit

Comparisons MocksConstr aints Static & Non-virtual methods Construc tors Concrete classes Sealed / Final classes Partial mocks.Net MoQXX TypemockXXXXXXX MS FakesXXXXXX Java JMock / EasyMock XX MockitoXXX JMockitXXXXXXX PowerMockXXXXXXX

Microsoft Fakes Comes with Visual Studio Provides “Stubs” and “Shims”. No constraints support StubsLike traditional mocks. Mock objects from interfaces. ShimsConcrete, final and static classes and methods.

PowerMock Java Framework Extensions to EasyMock and Mockito. Uses custom class loader and bytecode instrumentation.

References.Net Microsoft Fakes: us/library/hh aspxhttp://msdn.microsoft.com/en- us/library/hh aspx Typemock: Java Mockito: PowerMock: JMockit: