Top Banner
Unit Testing with Visual Studio 2012
17
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Unit testing with visual studio 2012

Unit Testing with Visual Studio 2012

Page 2: 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.

Page 3: Unit testing with visual studio 2012

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

Page 4: Unit testing with visual studio 2012

Quick overview of the new Unit Test Explorer window

Page 5: Unit testing with visual studio 2012

Developer Focused Unit Test Experience

Red-Green Bar

Most important

tests shown first

Timings

Shows tests from any

framework

Search

Run Details

Page 6: Unit testing with visual studio 2012

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!

Page 7: Unit testing with visual studio 2012

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

Page 8: Unit testing with visual studio 2012

• 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!

MS-Test Improvements

Page 9: Unit testing with visual studio 2012

Unit testing async methods with MS-Test

Page 10: Unit testing with visual studio 2012

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

Page 11: Unit testing with visual studio 2012

Using Fakes to create fast-running, isolated unit tests

Page 12: Unit testing with visual studio 2012

Code coverage in VS 2012Analyze 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

Page 13: Unit testing with visual studio 2012

Code Coverage

Page 14: Unit testing with visual studio 2012

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

Page 15: Unit testing with visual studio 2012

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

Page 16: Unit testing with visual studio 2012

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

Page 17: 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.