SlideShare a Scribd company logo
Quality Coding: What's New with Visual
              Studio 2012




  The newest release of Visual Studio 2012 is rich with new tools
  that enhance standard developer activities. In this session, we'll
  review and demonstrate some of these new features, such as
  Unit Testing, Code Reviews, Code Clones, and other developer
  tools. Come join us for this free Webinar!
Agenda
•   ALM and Quality

•   Quality in Requirements

•   Quality in Development
    –   Unit Testing
    –   Fakes
    –   Code Reviews
    –   Code Analysis
    –   Code Clones


•   Quality in Test
    –   Manual Testing
    –   Exploratory Testing
    –   Automated Testing
    –   Lab Environments


•   Conclusion
Recognizing the Iterative Nature of Applications

Initial Project Portfolio                                                                                                     Retire



                        Operate                                              Define
                        •Monitor                                             •Requirements
                        •Support                                             •Validation
                        •Upgrade                                             •Prioritization
                                                                             •Release Plan




                                          Develop
                                          •Iteration Plan
                                          •Develop                                                              Plan


                            Plan          •Test
                                                                                                         Done          Work
                                                                                           Plan
                                                 Plan
                     Done          Work
                                                                      Plan

                                                                                    Done          Work
                                          Done          Work

                                                               Done          Work
New ALM Capabilities in Visual Studio 2012




       Operate                Define
       •Monitor               •Requirements
       •Support               •Validation
       •Upgrade               •Prioritization
                              •Release Plan




            Develop
            •Iteration Plan
            •Develop
            •Test
Quality in Requirements: StoryBoarding
•   Tighter loop between the Business
    Stakeholders and Development Team

•   Graphical design tools built in
    PowerPoint

•   Embed other content including
    context slides

•   Capture screen shots and create
    lightweight animations

•   Store common elements within a
    shape library

•   Create master templates to simplify
    multiple similar views

•   Get feedback to others
     –   Email, print and version control the
         document
     –   leverage collaborative tools
     –   leverage web viewing tools
     –   Integration with TFS
Agenda
•   ALM and Quality

•   Quality in Requirements

•   Quality in Development
    –   Unit Testing
    –   Fakes
    –   Code Reviews
    –   Code Analysis
    –   Code Clones


•   Quality in Test
    –   Manual Testing
    –   Exploratory Testing
    –   Automated Testing
    –   Lab Environments


•   Conclusion
Why invest in quality?

• Quality is an expensive (and painful) afterthought




                  30

                  25

                  20
 Relative Cost
 To Fix Bugs...   15

                  10

                  5




                       Courtesy of the
                       National Institute of Software and Technology (NIST)
Problems...

• It is expensive to find and fix bugs that get past daily
  development practices
• It is hard to diagnose errors at runtime
• Why does an application run slowly?
• Individual Developers and Testers need to know if
  they are on track
• Test and development are often out of synch
• Final test phase for shipping is often ad-hoc
• How much testing is enough?
Approach for Development Quality

• Use 'defence in depth' strategy
  –   Unit testing
  –   Code reviews
  –   Continuous integration builds / Gated Check-ins
  –   Static Code Analysis
  –   Education / Patterns / Best Practices
Unit Testing Runner
New Test Runner:
• Tests run in background
• Run automatically on build
• Support for multiple unit
  testing frameworks:
   –   MS Test
   –   xUnit
   –   nUnit
   –   And More!
• Deep integration in the
  IDE
• Supports native C++ code
• Multiple run options
   – Failed Tests
   – Not-run Tests
   – All Tests
• Easy code coverage access
Unit Testing

• Diagnostic checks during development
  – Automated test script for methods on a type
  – Basic sanity checking
  – Useful for regression testing




     public double MethodA() { ... }




                                                                 test methods
                                                                 corresponding
                                                                 one or more
                                                                 Each method has
      public void TestMethodA()
      {
         SomeClass c = new SomeClass();   // Arrange
         double d = c.MethodA();                   // Act
         Assert.AreEqual(expected, d);             // Assert
      }
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!
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
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
DEMONSTRATION


• Unit Test Basics

• Framework Plug-Ins

• Unit Test Explorer

• Continuous Testing

• Code Coverage
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
• Generate Unit Test
   – Didn‟t actually generate a
     unit test
Unit Testing and Isolation

• Unit Tests verify the smallest testable „unit‟ of code
• Target code should be isolated from external
  influences
• Unit Test frameworks can perform integration testing

Unit Test Pseudo-Code:        Target Pseudo-Code:
  T = new SomeClass()         Function DoSomething(a)                 Response
  result = T.DoSomething(1)     x = LookupInDatabase(a)               controlled
  Assert.AreEqual(2,result)     y = ProcessWithWebService(x)
End Function                    LogToFile(“Processing complete”)
                                                                      by test
                              End Function




                                                                   Response
                                                                   controlled by test
                                                   Response
                                                   controlled
                                                   by test
What is un-testable code?

Where do we find it?                       Common indicators

•    “Get „er done” code                   •   Complex test setup and teardown
      –   Business logic in code-behind    •   Environmental dependencies
      –   Classes with too many            •   Public static methods
          dependencies
                                           •   Hidden object creation
      –   Database logic mixed with
          business logic                   •   Complex external frameworks
•    Testability was not a                 •   No tests at all!
     consideration
      –   Or was explicitly avoided
•    Monolithic, highly-coupled designs



      Any system where the tests require complex setup or
    where the tests run very slowly is unsuitable for the kind of
             developer testing we really care about.
A simple test setup example



The method we want to unit test

   bool IsFileEmpty(string file) {
       var content = File.ReadAllText(file);
       return content.Length == 0;
   }



   void FileExistsTest() {
       File.Write("foo.txt", "");
       var result = IsFileEmpty("foo.txt")
       Assert.IsTrue(result);
   }
Environmental Dependencies



Consider the following Y2K code:

  public void ThrowIfEndOfTheWorld()
  {
      if (DateTime.Now == new DateTime(2000,1,1))
          throw new Y2KBugException();
  }
Environmental Dependencies



How about this? Why is this bad?

  [DllImport("kernel32.dll")]
  extern static bool SetSystemTime(ref SystemTime time);

  [TestMethod]
  public void Y2KTest()
  {
      SetSystemTime(2000,1,1,0,0,0);
      Assert.Throws( () => ThrowIfEndOfTheWorld() );
  }
Isolating code with Microsoft Fakes


• The new VS 2012 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
Visual Studio 2012 Shims – Be Cautious

• Runtime interception of any .NET
  method
  – Uses the profiler to detour calls
  – “Monkey patching” for .NET


• Use it when you…
  – Have external components that cannot be
    refactored
     • SharePoint, ASP.NET, Office, etc.
  – Need to override non-virtual methods
     • Static methods, constructors, sealed
       types, properties
  – Have legacy code with untestable designs
Code Reviews


Purpose:
  – Find and fix bugs early in the process
    (much cheaper and easier than later)
  – Adherence to development standards
  – Improve consistency
  – Improve comments and maintainability
  – Share best practices across the team
  – Educate both experienced and new team
    members

  – Improve overall structural quality of the code and skillset of
    the team!
Integrated Code Review
• Provides
  feedback from
  other team
  members

• Shared
  knowledge
  across team

• Code reviews
  can be set as a
  quality gate

• Source changes
  highlighted and
  comments about
  the changes.
Automated Reviews?

• Static Code Analysis:
  – Analyze code (MSIL/SQL) based
    on best practices (rules)
  – Rules created by and used at Microsoft
  – Rulesets:
     • Selectable groups of rules allow tailoring to your environment
     • Rulesets can be further customized for the exact rules you need
  – Can support both T-SQL and .NET
  – Can be „enforced‟ using check-in policies
  – Can be reported during the build (including CI and Gated)


• Still not the same as manual/peer reviews
Code Clone Detection
•   Reviews common code
    blocks exposing
    refactoring
    opportunities

•   Detect code blocks with
    common structure and
    approach

•   Search is semantic, not
    just literal

•   Detects „copy and
    paste‟ errors

•   Detects code fragments
    with a common logical
    structure

•   Review common code
    and decide how to
    proceed
DEMONSTRATION



Code Reviews

Code Comparison

Static Analysis
Agenda
•   ALM and Quality

•   Quality in Requirements

•   Quality in Development
    –   Unit Testing
    –   Fakes
    –   Code Reviews
    –   Code Analysis
    –   Code Clones


•   Quality in Test
    –   Manual Testing
    –   Exploratory Testing
    –   Automated Testing
    –   Lab Environments


•   Conclusion
Changes in MTM 2012

•   Performance
•   Exploratory Testing
•   Multi-line test steps
•   Test data reduction through test settings
    configuration
•   Clone test suites via command line ("versioning")
•   Rich-text in test steps
•   Improved Test Step grid usability
•   Read-only test case access from within Test Runner
•   Pass/Fail test cases without using Test Runner
•   Enhanced view of results for Test Plan
•   Manual testing for Metro-style applications
Initiating Exploratory Testing



                             or no work item.




Explore based on specific work
          item(s)…
Performing Exploratory Testing


• Familiar Test Runner interface customized
  for exploratory testing

• Free-form comment area allows tester to
  record suggestions and problems
  encountered during the session

• Comment area allows for rich-
  text, attachments, and easy insertion of
  screenshot

• Session can be paused to perform activities
  outside of the Test Runner

• Bug and Test Case work items can readily
  be created during the exploratory testing
  session
Exploratory Testing Artifacts

                         During
                    exploring, we
                   want to capture
                   actions as a test                  Our testing steps
                        case for                      are captured and
                     regression…                      we can keep only
                                                       those related to
                                                          our bug.




 During exploring, we found a
bug. Let‟s create a work item…


        Here‟s all our steps, we can
        change them to create the
          test case exactly as we
                    want.
Questions?
Want to know more...?
Imaginet‟s New Visual Studio 2012 Website!
Visit Imaginet‟s new Visual Studio 2012 website, your one-stop
hub for all your Visual Studio 2012 needs!

         http://visualstudio.imaginet.com
For attendees of today‟s session that fill out the survey


Free Web Training Subscription Offer
• Receive 1 free Imaginet On Demand web training subscription
• Good for 1 person for 1 month


ALM Assessment Workshop
• One week on-site workshop
• 25% discount when ordered in the next 2 weeks*




* Only 1 discount allowed per customer per 6-month period
Upcoming Class – Tester Training with VS 2012

         Testers Training Using
      Visual Studio 2012 ALM Tools
              (4 Days Class)
This four-day instructor-led course provides students with the
knowledge and skills to use the latest testing tools provided by Visual
Studio 2012 to support a variety of different testing needs (manual
and automated).
Date:         November 12-16, 2012
Location:     Dallas (Irving, TX)
Price:        $2,375
     BONUS FOR WEBCAST ATTENDEES
     Buy one, get on for 50% off!
 Registration link will be included in our follow-up email later today!
TFS / Visual Studio 2012

             Upcoming Fall Workshops & Webcasts:
•   On-Demand Test Environments       •    Lean, Kanban, and TFS
     • October 25 (1:00-2:30pm CT)          • December 3 (1:00-2:30pm CT)

•   Quality Coding: What's New with   •    Approaches to Kanban with TFS
    Visual Studio 2012                      • December 6 (1:00-2:30pm CT)
     • October 29 (1:00-2:30pm CT)          • December 20 (1:00-2:30pm CT)

•   Branching and Merging and         •    Streamline Your Testing with Visual
    Bears, Oh My!                          Studio 2012 Testing Tools
     • November 1(1:00-2:00pm CT)           • December 13 (1:00-2:30pm CT)

•   Managing Test Labs Without the  •      Getting Started with Coded UI
    Headaches                              Testing: Building Your First
     • November 8 (1:00-2:30pm CT)         Automated Test
     • November 29 (1:00-2:30pm CT)         • December 17 (1:00-2:30pm CT)
ALM Planning & Implementation Services
ALM Planning                                                   Testing
•  ALM Assessment & Envisioning Workshops                      •  Manual Testing with Test Manager Quick
   (3 or 5 days)                                                  Start (5 days)
•  VS & TFS Migration Planning Workshop                        •  Visual Studio Testing Tools Quick Start
   (5 days)                                                       (10 days)
•  Microsoft Dev. Tools Deployment Planning                    •  Visual Studio Automated Testing Quick Start
    –   TFS Deployment Planning (5 days)                          (5 days)
    –   Visual SourceSafe to TFS Migration Planning (3 Days)
                                                               •  Visual Studio Load Testing Quick Start
    –   Visual Studio Quality Tools Deployment Planning
        (5 days)                                                  (5 or 10 Days)

TFS Adoption or Upgrade                                        Builds
•  TFS 2010 Adoption Quick Start                               •  Automated Build & Release Management
   (5 or 10 days)                                                 Quick Start (5 days)
•  TFS 2012 Adoption Quick Start                               •  Automated Build Center of Excellence (CoE)
   (5 or 10 days)
•  TFS 2010 Upgrade Quick Start (10 days)
                                                               Database
•  TFS 2012 Upgrade Quick Start (10 days)
                                                               •  Visual Studio Database Tools Quick Start
                                                                  (10 days)
Remote Support
• Remote Support for TFS & Visual Studio                       Integrations
                                                               •  Team Foundation Server (TFS) & Project
Lab                                                               Server Integration Quick Start (10 days)
•  Visual Studio Lab Management Quick Start                    •  TFS & Quality Center Integration/Migration
   (10 days)                                                      Quick Start (10 days)
                                                Email us at:
For questions or more information,
      please contact us at:

info@imaginet.com or (972)607-4830
http://www.imaginet.com

More Related Content

PDF
PDF
Testing in the lifecycle
PPTX
Scaling Kanban in the Enterprise with GreenHopper
PDF
Vaidyanathan Ramalingam Waterfall Vs Agile Testing Conference Speech
PDF
Vaidyanathan Ramalingam Silicon India Testing Conference 2 July2011 Speech
PDF
Vaidyanathan Ramalingam Trade Off Economics In Testing Conference Speech
PDF
Vaidyanathan Ramalingam Agile Testing Conference Speech
PDF
Vaidyanathan Ramalingam Agile Testing Leadership Lessons Softec 2 July2011
Testing in the lifecycle
Scaling Kanban in the Enterprise with GreenHopper
Vaidyanathan Ramalingam Waterfall Vs Agile Testing Conference Speech
Vaidyanathan Ramalingam Silicon India Testing Conference 2 July2011 Speech
Vaidyanathan Ramalingam Trade Off Economics In Testing Conference Speech
Vaidyanathan Ramalingam Agile Testing Conference Speech
Vaidyanathan Ramalingam Agile Testing Leadership Lessons Softec 2 July2011

What's hot (14)

PDF
Vaidyanathan Ramalingam Testing Checklist Conference Speech
PDF
Vaidyanathan Ramalingam Software Testing Eco System Conference Speech
PDF
PDF
Vaidyanathan Ramalingam Rca In Agile Conference Speech
PDF
Vaidyanathan Ramalingam Rca In Testing Conference Speech
PPTX
Upgrading to TFS 2012: What You Need to Know!
PDF
test
PDF
Agile Testing Introduction
PDF
Постоянное тестирование интеграции
PPT
PowerPoint Presentation
PDF
Shirly Ronen - User story testing activities
PDF
Why Test Driven Development?
PDF
Alliance Successful Selenium Automation
PDF
Shirly Ronen - Documenting an agile defect
Vaidyanathan Ramalingam Testing Checklist Conference Speech
Vaidyanathan Ramalingam Software Testing Eco System Conference Speech
Vaidyanathan Ramalingam Rca In Agile Conference Speech
Vaidyanathan Ramalingam Rca In Testing Conference Speech
Upgrading to TFS 2012: What You Need to Know!
test
Agile Testing Introduction
Постоянное тестирование интеграции
PowerPoint Presentation
Shirly Ronen - User story testing activities
Why Test Driven Development?
Alliance Successful Selenium Automation
Shirly Ronen - Documenting an agile defect
Ad

Similar to Quality Coding with Visual Studio 2012 (20)

PDF
Agile Software Development in Practice - A Developer Perspective
PDF
Unit testingandcontinousintegrationfreenest1dot4
PDF
Agile Software Development Process Practice in Thai Culture
PPTX
Session #1: Development Practices And The Microsoft Approach
PPTX
Unosquare SlideShare Presentation
PPTX
Distributed agile testing_for_enterprises
PPTX
PHX Session #1: Development Best Practices And How Microsoft Helps
PDF
Effective Strategies for Distributed Testing
DOCX
Journey of a tester from Waterfall to Agile/Kanban Land - Hebrew
PPTX
How to bake in quality in agile scrum projects
PDF
Inverting The Testing Pyramid
PDF
Keynote: Next Generation Testing
PPTX
Answer powerpoint template
PDF
Testing for continuous delivery with visual studio 2012
PPT
Chapter 1 ASE Slides ppt
PPTX
Testing Sap: Modern Methodology
PDF
Behavior Driven Development (BDD)
PPT
Paper PsUpload
PPT
justin presentation upload PPT june 19
PPT
justin presentation Slideshare PPT upload June 25 Final one
Agile Software Development in Practice - A Developer Perspective
Unit testingandcontinousintegrationfreenest1dot4
Agile Software Development Process Practice in Thai Culture
Session #1: Development Practices And The Microsoft Approach
Unosquare SlideShare Presentation
Distributed agile testing_for_enterprises
PHX Session #1: Development Best Practices And How Microsoft Helps
Effective Strategies for Distributed Testing
Journey of a tester from Waterfall to Agile/Kanban Land - Hebrew
How to bake in quality in agile scrum projects
Inverting The Testing Pyramid
Keynote: Next Generation Testing
Answer powerpoint template
Testing for continuous delivery with visual studio 2012
Chapter 1 ASE Slides ppt
Testing Sap: Modern Methodology
Behavior Driven Development (BDD)
Paper PsUpload
justin presentation upload PPT june 19
justin presentation Slideshare PPT upload June 25 Final one
Ad

More from Imaginet (20)

PPTX
Industry 4.0 Changes Everything
PPTX
Introduction to Kanban
PPTX
Top Business Benefits of Application Lifecycle Management (ALM)
PPTX
Upgrading to Team Foundation Server (TFS) 2012 – What You Need to Know! (07-2...
PPTX
Introduction to Kanban
PDF
Getting Started With Coded UI testing: Building Your First Automated Test
PPTX
Managing Test Labs Without the Headaches
PPTX
Getting Started with Visual Studio’s Coded UI Testing: Building Your First Au...
PDF
Managing Test Labs Without the Headaches
PPTX
Quality Coding: What's New with Visual Studio 2012
PPTX
New SharePoint Developer Tools in Visual Studio 2012
PPTX
Quality Coding: What’s New with Visual Studio 2012
PPTX
Lean, Kanban and TFS
PPTX
The Newest of the New with Visual Studio and TFS 2012
PPTX
The Newest of the New with Visual Studio and TFS 2012
PPTX
Using Lean and Kanban to Revolutionize Your Organization
PPTX
Lean, Kanban, and TFS
PPTX
How Microsoft ALM Tools Can Improve Your Bottom Line
PPTX
Getting Started with Coded UI Testing: Building Your First Automated Test
PPTX
Upgrading to Team Foundation Server (TFS) 2012 – What You Need to Know!
Industry 4.0 Changes Everything
Introduction to Kanban
Top Business Benefits of Application Lifecycle Management (ALM)
Upgrading to Team Foundation Server (TFS) 2012 – What You Need to Know! (07-2...
Introduction to Kanban
Getting Started With Coded UI testing: Building Your First Automated Test
Managing Test Labs Without the Headaches
Getting Started with Visual Studio’s Coded UI Testing: Building Your First Au...
Managing Test Labs Without the Headaches
Quality Coding: What's New with Visual Studio 2012
New SharePoint Developer Tools in Visual Studio 2012
Quality Coding: What’s New with Visual Studio 2012
Lean, Kanban and TFS
The Newest of the New with Visual Studio and TFS 2012
The Newest of the New with Visual Studio and TFS 2012
Using Lean and Kanban to Revolutionize Your Organization
Lean, Kanban, and TFS
How Microsoft ALM Tools Can Improve Your Bottom Line
Getting Started with Coded UI Testing: Building Your First Automated Test
Upgrading to Team Foundation Server (TFS) 2012 – What You Need to Know!

Recently uploaded (20)

PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Spectroscopy.pptx food analysis technology
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
A Presentation on Artificial Intelligence
PPTX
Machine Learning_overview_presentation.pptx
PPT
Teaching material agriculture food technology
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Big Data Technologies - Introduction.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Spectroscopy.pptx food analysis technology
MIND Revenue Release Quarter 2 2025 Press Release
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
A Presentation on Artificial Intelligence
Machine Learning_overview_presentation.pptx
Teaching material agriculture food technology
Advanced methodologies resolving dimensionality complications for autism neur...
Building Integrated photovoltaic BIPV_UPV.pdf
Spectral efficient network and resource selection model in 5G networks
Big Data Technologies - Introduction.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Electronic commerce courselecture one. Pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
gpt5_lecture_notes_comprehensive_20250812015547.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
NewMind AI Weekly Chronicles - August'25-Week II
20250228 LYD VKU AI Blended-Learning.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
Reach Out and Touch Someone: Haptics and Empathic Computing

Quality Coding with Visual Studio 2012

  • 1. Quality Coding: What's New with Visual Studio 2012 The newest release of Visual Studio 2012 is rich with new tools that enhance standard developer activities. In this session, we'll review and demonstrate some of these new features, such as Unit Testing, Code Reviews, Code Clones, and other developer tools. Come join us for this free Webinar!
  • 2. Agenda • ALM and Quality • Quality in Requirements • Quality in Development – Unit Testing – Fakes – Code Reviews – Code Analysis – Code Clones • Quality in Test – Manual Testing – Exploratory Testing – Automated Testing – Lab Environments • Conclusion
  • 3. Recognizing the Iterative Nature of Applications Initial Project Portfolio Retire Operate Define •Monitor •Requirements •Support •Validation •Upgrade •Prioritization •Release Plan Develop •Iteration Plan •Develop Plan Plan •Test Done Work Plan Plan Done Work Plan Done Work Done Work Done Work
  • 4. New ALM Capabilities in Visual Studio 2012 Operate Define •Monitor •Requirements •Support •Validation •Upgrade •Prioritization •Release Plan Develop •Iteration Plan •Develop •Test
  • 5. Quality in Requirements: StoryBoarding • Tighter loop between the Business Stakeholders and Development Team • Graphical design tools built in PowerPoint • Embed other content including context slides • Capture screen shots and create lightweight animations • Store common elements within a shape library • Create master templates to simplify multiple similar views • Get feedback to others – Email, print and version control the document – leverage collaborative tools – leverage web viewing tools – Integration with TFS
  • 6. Agenda • ALM and Quality • Quality in Requirements • Quality in Development – Unit Testing – Fakes – Code Reviews – Code Analysis – Code Clones • Quality in Test – Manual Testing – Exploratory Testing – Automated Testing – Lab Environments • Conclusion
  • 7. Why invest in quality? • Quality is an expensive (and painful) afterthought 30 25 20 Relative Cost To Fix Bugs... 15 10 5 Courtesy of the National Institute of Software and Technology (NIST)
  • 8. Problems... • It is expensive to find and fix bugs that get past daily development practices • It is hard to diagnose errors at runtime • Why does an application run slowly? • Individual Developers and Testers need to know if they are on track • Test and development are often out of synch • Final test phase for shipping is often ad-hoc • How much testing is enough?
  • 9. Approach for Development Quality • Use 'defence in depth' strategy – Unit testing – Code reviews – Continuous integration builds / Gated Check-ins – Static Code Analysis – Education / Patterns / Best Practices
  • 10. Unit Testing Runner New Test Runner: • Tests run in background • Run automatically on build • Support for multiple unit testing frameworks: – MS Test – xUnit – nUnit – And More! • Deep integration in the IDE • Supports native C++ code • Multiple run options – Failed Tests – Not-run Tests – All Tests • Easy code coverage access
  • 11. Unit Testing • Diagnostic checks during development – Automated test script for methods on a type – Basic sanity checking – Useful for regression testing public double MethodA() { ... } test methods corresponding one or more Each method has public void TestMethodA() { SomeClass c = new SomeClass(); // Arrange double d = c.MethodA(); // Act Assert.AreEqual(expected, d); // Assert }
  • 12. 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)
  • 13. 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!
  • 14. 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
  • 15. 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
  • 16. DEMONSTRATION • Unit Test Basics • Framework Plug-Ins • Unit Test Explorer • Continuous Testing • Code Coverage
  • 17. 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 • Generate Unit Test – Didn‟t actually generate a unit test
  • 18. Unit Testing and Isolation • Unit Tests verify the smallest testable „unit‟ of code • Target code should be isolated from external influences • Unit Test frameworks can perform integration testing Unit Test Pseudo-Code: Target Pseudo-Code: T = new SomeClass() Function DoSomething(a) Response result = T.DoSomething(1) x = LookupInDatabase(a) controlled Assert.AreEqual(2,result) y = ProcessWithWebService(x) End Function LogToFile(“Processing complete”) by test End Function Response controlled by test Response controlled by test
  • 19. What is un-testable code? Where do we find it? Common indicators • “Get „er done” code • Complex test setup and teardown – Business logic in code-behind • Environmental dependencies – Classes with too many • Public static methods dependencies • Hidden object creation – Database logic mixed with business logic • Complex external frameworks • Testability was not a • No tests at all! consideration – Or was explicitly avoided • Monolithic, highly-coupled designs Any system where the tests require complex setup or where the tests run very slowly is unsuitable for the kind of developer testing we really care about.
  • 20. A simple test setup example The method we want to unit test bool IsFileEmpty(string file) { var content = File.ReadAllText(file); return content.Length == 0; } void FileExistsTest() { File.Write("foo.txt", ""); var result = IsFileEmpty("foo.txt") Assert.IsTrue(result); }
  • 21. Environmental Dependencies Consider the following Y2K code: public void ThrowIfEndOfTheWorld() { if (DateTime.Now == new DateTime(2000,1,1)) throw new Y2KBugException(); }
  • 22. Environmental Dependencies How about this? Why is this bad? [DllImport("kernel32.dll")] extern static bool SetSystemTime(ref SystemTime time); [TestMethod] public void Y2KTest() { SetSystemTime(2000,1,1,0,0,0); Assert.Throws( () => ThrowIfEndOfTheWorld() ); }
  • 23. Isolating code with Microsoft Fakes • The new VS 2012 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
  • 24. Visual Studio 2012 Shims – Be Cautious • Runtime interception of any .NET method – Uses the profiler to detour calls – “Monkey patching” for .NET • Use it when you… – Have external components that cannot be refactored • SharePoint, ASP.NET, Office, etc. – Need to override non-virtual methods • Static methods, constructors, sealed types, properties – Have legacy code with untestable designs
  • 25. Code Reviews Purpose: – Find and fix bugs early in the process (much cheaper and easier than later) – Adherence to development standards – Improve consistency – Improve comments and maintainability – Share best practices across the team – Educate both experienced and new team members – Improve overall structural quality of the code and skillset of the team!
  • 26. Integrated Code Review • Provides feedback from other team members • Shared knowledge across team • Code reviews can be set as a quality gate • Source changes highlighted and comments about the changes.
  • 27. Automated Reviews? • Static Code Analysis: – Analyze code (MSIL/SQL) based on best practices (rules) – Rules created by and used at Microsoft – Rulesets: • Selectable groups of rules allow tailoring to your environment • Rulesets can be further customized for the exact rules you need – Can support both T-SQL and .NET – Can be „enforced‟ using check-in policies – Can be reported during the build (including CI and Gated) • Still not the same as manual/peer reviews
  • 28. Code Clone Detection • Reviews common code blocks exposing refactoring opportunities • Detect code blocks with common structure and approach • Search is semantic, not just literal • Detects „copy and paste‟ errors • Detects code fragments with a common logical structure • Review common code and decide how to proceed
  • 30. Agenda • ALM and Quality • Quality in Requirements • Quality in Development – Unit Testing – Fakes – Code Reviews – Code Analysis – Code Clones • Quality in Test – Manual Testing – Exploratory Testing – Automated Testing – Lab Environments • Conclusion
  • 31. Changes in MTM 2012 • Performance • Exploratory Testing • Multi-line test steps • Test data reduction through test settings configuration • Clone test suites via command line ("versioning") • Rich-text in test steps • Improved Test Step grid usability • Read-only test case access from within Test Runner • Pass/Fail test cases without using Test Runner • Enhanced view of results for Test Plan • Manual testing for Metro-style applications
  • 32. Initiating Exploratory Testing or no work item. Explore based on specific work item(s)…
  • 33. Performing Exploratory Testing • Familiar Test Runner interface customized for exploratory testing • Free-form comment area allows tester to record suggestions and problems encountered during the session • Comment area allows for rich- text, attachments, and easy insertion of screenshot • Session can be paused to perform activities outside of the Test Runner • Bug and Test Case work items can readily be created during the exploratory testing session
  • 34. Exploratory Testing Artifacts During exploring, we want to capture actions as a test Our testing steps case for are captured and regression… we can keep only those related to our bug. During exploring, we found a bug. Let‟s create a work item… Here‟s all our steps, we can change them to create the test case exactly as we want.
  • 36. Want to know more...?
  • 37. Imaginet‟s New Visual Studio 2012 Website! Visit Imaginet‟s new Visual Studio 2012 website, your one-stop hub for all your Visual Studio 2012 needs! http://visualstudio.imaginet.com
  • 38. For attendees of today‟s session that fill out the survey Free Web Training Subscription Offer • Receive 1 free Imaginet On Demand web training subscription • Good for 1 person for 1 month ALM Assessment Workshop • One week on-site workshop • 25% discount when ordered in the next 2 weeks* * Only 1 discount allowed per customer per 6-month period
  • 39. Upcoming Class – Tester Training with VS 2012 Testers Training Using Visual Studio 2012 ALM Tools (4 Days Class) This four-day instructor-led course provides students with the knowledge and skills to use the latest testing tools provided by Visual Studio 2012 to support a variety of different testing needs (manual and automated). Date: November 12-16, 2012 Location: Dallas (Irving, TX) Price: $2,375 BONUS FOR WEBCAST ATTENDEES Buy one, get on for 50% off! Registration link will be included in our follow-up email later today!
  • 40. TFS / Visual Studio 2012 Upcoming Fall Workshops & Webcasts: • On-Demand Test Environments • Lean, Kanban, and TFS • October 25 (1:00-2:30pm CT) • December 3 (1:00-2:30pm CT) • Quality Coding: What's New with • Approaches to Kanban with TFS Visual Studio 2012 • December 6 (1:00-2:30pm CT) • October 29 (1:00-2:30pm CT) • December 20 (1:00-2:30pm CT) • Branching and Merging and • Streamline Your Testing with Visual Bears, Oh My! Studio 2012 Testing Tools • November 1(1:00-2:00pm CT) • December 13 (1:00-2:30pm CT) • Managing Test Labs Without the • Getting Started with Coded UI Headaches Testing: Building Your First • November 8 (1:00-2:30pm CT) Automated Test • November 29 (1:00-2:30pm CT) • December 17 (1:00-2:30pm CT)
  • 41. ALM Planning & Implementation Services ALM Planning Testing • ALM Assessment & Envisioning Workshops • Manual Testing with Test Manager Quick (3 or 5 days) Start (5 days) • VS & TFS Migration Planning Workshop • Visual Studio Testing Tools Quick Start (5 days) (10 days) • Microsoft Dev. Tools Deployment Planning • Visual Studio Automated Testing Quick Start – TFS Deployment Planning (5 days) (5 days) – Visual SourceSafe to TFS Migration Planning (3 Days) • Visual Studio Load Testing Quick Start – Visual Studio Quality Tools Deployment Planning (5 days) (5 or 10 Days) TFS Adoption or Upgrade Builds • TFS 2010 Adoption Quick Start • Automated Build & Release Management (5 or 10 days) Quick Start (5 days) • TFS 2012 Adoption Quick Start • Automated Build Center of Excellence (CoE) (5 or 10 days) • TFS 2010 Upgrade Quick Start (10 days) Database • TFS 2012 Upgrade Quick Start (10 days) • Visual Studio Database Tools Quick Start (10 days) Remote Support • Remote Support for TFS & Visual Studio Integrations • Team Foundation Server (TFS) & Project Lab Server Integration Quick Start (10 days) • Visual Studio Lab Management Quick Start • TFS & Quality Center Integration/Migration (10 days) Quick Start (10 days) Email us at:
  • 42. For questions or more information, please contact us at: [email protected] or (972)607-4830

Editor's Notes

  • #2: This is the teaser for the class – we will preview (in slides) many of the topics that we’ll dive into deeply as part of this training class…
  • #8: This is the teaser for the class – we will preview (in slides) many of the topics that we’ll dive into deeply as part of this training class…
  • #16: Speaker notes:1. While we are expanding support for 3rd party frameworks, we have lots of customers who are on MSTest and we will continue investing in it for them2. Potential rude QA, Mstest sucks because….Where is Assert.Throws?Where is DataRow support?Answer: We are fully aware that we are behind on some key features, we are not done yet and will keep working to close the gap here
  • #19: As needed, use this as an opportunity to demonstrate work items in general. For an upgrade class, hopefully this is minimized.
  • #21: Peter – fix the final sentence this time. 
  • #26: Image source: http://www.sxc.hu/photo/1125087
  • #27: As needed, use this as an opportunity to demonstrate work items in general. For an upgrade class, hopefully this is minimized.
  • #28: Maybe retitle this?
  • #29: There are also things like JSLint, etc. for other platforms
  • #33: As needed, use this as an opportunity to demonstrate work items in general. For an upgrade class, hopefully this is minimized.
  • #34: This is the teaser for the class – we will preview (in slides) many of the topics that we’ll dive into deeply as part of this training class…
  • #35: Source: http://blogs.msdn.com/b/visualstudioalm/archive/2012/02/29/what-s-new-for-microsoft-test-manager-in-visual-studio-11-beta.aspx?PageIndex=2#comments
  • #40: Want to know more?
  • #47: Want to know more?