300 likes | 473 Views
DEV214. Introducing the New Visual Studio 2012 Unit Testing Experience. Peter Provost Sr. Program Manager Lead Microsoft Corporation. The Visual Studio 11 Unit Testing experience is focused on developers writing and running unit tests while they write their code.
E N D
DEV214 Introducing the New Visual Studio 2012 Unit Testing Experience Peter Provost Sr. Program Manager Lead Microsoft Corporation
The Visual Studio 11 Unit Testing experience is focused on developers writing and running unit tests while they write their code.
Years of customer feedback • Customers want to use other frameworks for unit testing • MS-Test had a reputation for being slower than other managed frameworks • No real support for non-managed projects and test frameworks • MS-Test very slow to evolve as the unit testing world changes (e.g. xUnit.net, BDD frameworks, mocking frameworks, etc.) • The VS experience feels like it was designed for testers not developers • Agile development and TDD approaches aren’t supported well by the current unit test experience
Architecture Visual Studio Unit Test Explorer Command Line Runner TeamBuild Unit Test Activity Visual Studio Unit Test Platform MS-Test Managed MS-Test Native NUnit xUnit.net QUnit MORE!
Developer Focused Unit Test Experience Search Red-Green Bar Most important tests shown first Timings Shows tests from any framework Run Details
Use the framework you want to use • In the box support for • MS-Test Managed • MS-Test Native (**NEW**) • Third party plugins currently under development • NUnit • xUnit.net • MbUnit • SQL Server Unit Testing • More!
MS-Test Improvements • Many performance and scale improvements • Especially 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-targeting • Available in Express!
Strong Compatibility with VS2010 • VS2010 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 testing • The new VS11 Fakes framework lets you test almost ANYTHING in isolation, even when it has external dependencies • Derived from Microsoft Research “Moles” project • Fakes come in two flavors • Stubs – concrete implementations of interfaces or abstract classes that you can pass in to your system-under-test to isolate it from real implementations • Shims – generated classes that enable you to intercept and replace calls to existing classes, even those from the .NET BCL!
Using Fakes to create fast-running, isolated unit tests demo
Recommendations • Stubs • A natural extension of well known testing strategies • You should feel good about using them in your tests. • Shims • Are amazingly powerful and sometimes the only way to test certain things… but they are evil! • Use Shims to get your code under test • But don’t stop there… • Strive to refactor the code so you don’t need the Shims anymore • Then remove them
Code coverage in VS11 • Analyze your code coverage with a single click • Analyze for selected tests to help find how specific tests are covering your system • Supports native code (via the MS-Test Native framework) • Works with third party managed & native frameworks
Code Coverage demo
Team Build Support • If it works in VS, it works on Team Build • 3rd party frameworks • Visual Studio Fakes Isolation Framework • Code Coverage • Plus… • Hosted Build (Team Build in the Cloud) • Test Impact Analysis
Continuous Testing • Running your Unit Tests should be a natural part of doing a build • “Run Tests After Build” option will run your Unit Tests after each successful build
Continuous Testing demo
But wait there’s more! • Sharepoint Development • COMING SOON!Fakes Behaviors Library for Sharepoint Unit Testing • Available in Win8 Express and Web Express! • The same unit testing experience • No extensibility (3rd party framework) • No continuous test runner • No fakes framework
What’s missing? • Test Lists • Legacy mode only • Test Impact • Works on the server, not in the VS client • Private accessors • Deprecated in VS2010, remove in VS11
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 mics • I will stick around outside after Think of a question later? peter.provost@microsoft.com www.peterprovost.org @pprovost Peter Provost Find Me Later At DEV01-TLC: Application Lifecycle Management (ALM)
Related Content • Breakout Sessions • DEV214 Introducing the New Visual Studio 11 Unit Testing Experience • AAP401 Real World Developer Testing with Visual Studio 2012 • DEV411 Testing Un-testable Code with Fakes in Visual Studio 2012 • AAP330 Compile & Execute Requirements in .NET • Hands on Labs • DEV17-HOL Explore the New Unit Testing and Code Clone Capabilities of Visual Studio 2012 • Product Demo Stations • DEV01-TLCApplication Lifecycle Management (ALM)
DEV Track Resources • Visual Studio Home Page :: http://www.microsoft.com/visualstudio/en-us • Somasegar’s Blog :: http://blogs.msdn.com/b/somasegar/ • Jason Zander’s Blog :: http://blogs.msdn.com/b/jasonz/ • Facebook :: http://www.facebook.com/visualstudio • Twitter :: http://twitter.com/#!/visualstudio
Resources Learning TechNet • Connect. Share. Discuss. • Microsoft Certification & Training Resources http://northamerica.msteched.com www.microsoft.com/learning • Resources for IT Professionals • Resources for Developers • http://microsoft.com/technet http://microsoft.com/msdn
Required Slide Complete an evaluation on CommNet and enter to win!
MS Tag Scan the Tag to evaluate this session now on myTechEd Mobile
© 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.