Unit Testing with Visual
      Studio 2012
The Visual Studio 2012 Unit Testing
     experience is focused on
developers writing and running unit
 tests while they write their code.
Years of customer feedback
• MS-Test Framework Issues
   • MS-Test too slow
   • Bad C/C++ support
   • MS-Test missing new features
• Experience Issues
   • Designed for testers not developers
   • Not good for Agile & TDD
Quick overview of the new Unit Test
Explorer window
Developer Focused Unit Test Experience
Architecture
Use the framework you want to use
• In the box support for
   • .NET
   • Native C/C++
• Third party plugins
   •   NUnit
   •   xUnit.net
   •   MbUnit
   •   QUnit/Jasmine
   •   SQL Server Unit Testing
        • Under development
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!
Unit testing async methods with MS-Test
Isolating code for better testing
• The new VS11 Fakes framework lets you
  isolate almost ANYTHING in .NET
• Fakes come in two flavors
  • Stubs – concrete implementations of
    interfaces or abstract classes
  • Shims – run-time interception lets you
    replace calls, even those from the .NET BCL
Using Fakes to create fast-
running, isolated unit tests
Code coverage in VS 2012
Analyze your code
coverage with a
single click
Analyze for selected
tests to help find
how specific tests
are covering your
system
Supports all
managed & native
frameworks
Code Coverage
Team Foundation Build
• If it works in Visual Studio, it works on
  Team Foundation Build
   • 3rd party frameworks
   • Visual Studio Fakes Isolation Framework
   • Code Coverage

• Plus…
   • Hosted Build (Team Build in the Cloud)
   • Test Impact Analysis
Continuous Testing
• “If you aren’t running your unit
  tests, you are just compiling. You are
  not building.”
                   Chris Patterson
                   Program Manager
                   Team Foundation Build


• Run Tests After Build option in Visual
  Studio 2012 will run your Unit Tests
  after each successful build of your
  solution
What’s missing?

• Test Lists
   • Legacy mode only
• Test Impact
   • Works on the server, not in the VS client
• Private accessors
   • Deprecated in VS 2010, removed in VS
     2012
The Visual Studio 2012 Unit Testing
     experience is focused on
developers writing and running unit
 tests while they write their code.

Unit testing with visual studio 2012

  • 1.
    Unit Testing withVisual Studio 2012
  • 2.
    The Visual Studio2012 Unit Testing experience is focused on developers writing and running unit tests while they write their code.
  • 3.
    Years of customerfeedback • MS-Test Framework Issues • MS-Test too slow • Bad C/C++ support • MS-Test missing new features • Experience Issues • Designed for testers not developers • Not good for Agile & TDD
  • 4.
    Quick overview ofthe new Unit Test Explorer window
  • 5.
    Developer Focused UnitTest Experience
  • 6.
  • 7.
    Use the frameworkyou want to use • In the box support for • .NET • Native C/C++ • Third party plugins • NUnit • xUnit.net • MbUnit • QUnit/Jasmine • SQL Server Unit Testing • Under development
  • 8.
    MS-Test Improvements • Manyperformance 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!
  • 9.
    Unit testing asyncmethods with MS-Test
  • 10.
    Isolating code forbetter testing • The new VS11 Fakes framework lets you isolate almost ANYTHING in .NET • Fakes come in two flavors • Stubs – concrete implementations of interfaces or abstract classes • Shims – run-time interception lets you replace calls, even those from the .NET BCL
  • 11.
    Using Fakes tocreate fast- running, isolated unit tests
  • 12.
    Code coverage inVS 2012 Analyze your code coverage with a single click Analyze for selected tests to help find how specific tests are covering your system Supports all managed & native frameworks
  • 13.
  • 14.
    Team Foundation Build •If it works in Visual Studio, it works on Team Foundation Build • 3rd party frameworks • Visual Studio Fakes Isolation Framework • Code Coverage • Plus… • Hosted Build (Team Build in the Cloud) • Test Impact Analysis
  • 15.
    Continuous Testing • “Ifyou aren’t running your unit tests, you are just compiling. You are not building.” Chris Patterson Program Manager Team Foundation Build • Run Tests After Build option in Visual Studio 2012 will run your Unit Tests after each successful build of your solution
  • 16.
    What’s missing? • TestLists • Legacy mode only • Test Impact • Works on the server, not in the VS client • Private accessors • Deprecated in VS 2010, removed in VS 2012
  • 17.
    The Visual Studio2012 Unit Testing experience is focused on developers writing and running unit tests while they write their code.