Introducing the New Visual Studio 2012 Unit Testing Experience

29
Introducing the New Visual Studio 2012 Unit Testing Experience Peter Provost Sr. Program Manager Lead Microsoft Corporation DEV214

Transcript of Introducing the New Visual Studio 2012 Unit Testing Experience

Introducing the New Visual Studio 2012 Unit Testing ExperiencePeter ProvostSr. Program Manager LeadMicrosoft Corporation

DEV214

The Visual Studio 11 Unit Testing experience is focused

on developers writing and running unit tests while they

write their code.

Years of customer feedbackMS-Test Framework Issues

MS-Test too slowBad C/C++ supportMS-Test missing new features

Experience IssuesDesigned for testers not developersNot good for Agile & TDD

Quick overview of the new Unit Test Explorer window

Developer Focused Unit Test ExperienceRed-Green

BarMost

important tests shown

first

Timings

Shows tests from any

framework

Search

Run Details

Architecture

Visual Studio Unit Test Explorer

Command Line Runner

TeamBuild Unit Test Activity

Visual Studio Unit Test Platform

MS-Test Manage

dMS-Test Native NUnit xUnit.ne

t QUnit MORE!

Use the framework you want to useIn the box support for

.NET Native C/C++

Third party pluginsNUnitxUnit.netMbUnitQUnit/JasmineSQL Server Unit Testing

Under development

Many performance and scale improvementsEspecially when you stick to “classic” unit testing

Support for testing Async[TestMethod]public async Task MyAsyncTest(){

var result = await SomeLongRunningOperation();Assert.IsTrue( result );

}

Proper support for 64-bit and .Net multi-targetingAvailable in Express!

MS-Test Improvements

Unit testing async methods with MS-Test

Strong Compatibility with VS2010VS2010 Unit Test Projects should “just work” in VS11 without any upgrade (and round-trip back to VS 2010)TeamBuild in TFS 11 can be configured to use the VS2010 compatible runner or the new VS11 runner

Isolating code for better testingThe new VS11 Fakes framework lets you isolate almost ANYTHING in .NETFakes come in two flavors

Stubs – concrete implementations of interfaces or abstract classesShims – run-time interception lets you replace calls, even those from the .NET BCL

Using Fakes to create fast-running, isolated unit tests

RecommendationsStubs

A natural extension of well known testing strategiesYou should feel good about using them in your tests.

ShimsAre amazingly powerful and sometimes the only way to test certain things… but they are evil! Use Shims to get your code under testBut don’t stop there…Strive to refactor the code so you don’t need the Shims anymoreThen remove them

For a deep-dive on fakes DEV411: Testing Un-testable Code with Fakes

Code coverage in VS11Analyze your code coverage with a single clickAnalyze for selected tests to help find how specific tests are covering your systemSupports all managed & native frameworks

Code Coverage

Team Foundation BuildIf it works in Visual Studio, it works on Team Foundation Build

3rd party frameworksVisual Studio Fakes Isolation FrameworkCode Coverage

Plus…Hosted Build (Team Build in the Cloud)Test Impact Analysis

Unit Testing on Team Build in the Cloud

Continuous Testing“If you aren’t running your unit tests, you are just compiling. You are not building.”

Chris PattersonProgram ManagerTeam Foundation Build

Run Tests After Build option in Visual Studio 2012 will run your Unit Tests after each successful build of your solution

Continuous Testing

But wait there’s more!Sharepoint Development

COMING SOON!Test Emulation Library forSharepoint Unit Testing

Available in Visual Studio Express 2012

The same unit testing experienceNo extensibility (3rd party framework)No continuous test runnerNo fakes framework

What’s missing?Test Lists

Legacy mode onlyTest Impact

Works on the server, not in the VS client

Private accessorsDeprecated in VS 2010, removed in VS 2012

The Visual Studio 11 Unit Testing experience is focused

on developers writing and running unit tests while they

write their code.

Thank you!Have questions now?

Please use the micsI will stick around outside after

Think of a question [email protected]@pprovost

Peter Provost

Find Me Later At DEV01-TLC: Application Lifecycle Management (ALM)

Related ContentBreakout Sessions

DEV214 Introducing the New Visual Studio 11 Unit Testing ExperienceAAP401 Real World Developer Testing with Visual Studio 2012DEV411 Testing Un-testable Code with Fakes in Visual Studio 2012AAP330 Compile & Execute Requirements in .NETHands on LabsDEV17-HOL Explore the New Unit Testing and Code Clone Capabilities of

Visual Studio 2012Product Demo Stations

DEV01-TLC Application Lifecycle Management (ALM)

DEV Track ResourcesVisual Studio Home Page :: http://www.microsoft.com/visualstudio/en-us

Jason Zander’s Blog :: http://blogs.msdn.com/b/jasonz/

Facebook :: http://www.facebook.com/visualstudio

Twitter :: http://twitter.com/#!/visualstudio

Somasegar’s Blog :: http://blogs.msdn.com/b/somasegar/

Resources

Connect. Share. Discuss.http://europe.msteched.com

Learning

Microsoft Certification & Training Resourceswww.microsoft.com/learning

TechNet

Resources for IT Professionalshttp://microsoft.com/technet

Resources for Developershttp://microsoft.com/msdn

Evaluations

http://europe.msteched.com/sessions

Submit your evals online

© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to

be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS

PRESENTATION.