unit testing, ui testing and test driven development in visual studio 2012

28
unit testing, ui testing, & test-driven development in visual studio 2012 Jon Limjap C# MVP

Upload: jon-limjap

Post on 11-Nov-2014

5.445 views

Category:

Technology


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Unit testing, UI testing and Test Driven Development in Visual Studio 2012

unit testing, ui testing, & test-driven development in visual studio 2012

Jon LimjapC# MVP

Page 2: Unit testing, UI testing and Test Driven Development in Visual Studio 2012

Agenda

• Overview of Unit Testing, UI Testing and Test Driven Development

• Unit testing UI and code in Visual Studio 2012

Page 3: Unit testing, UI testing and Test Driven Development in Visual Studio 2012

overview of unit testing, ui testing, and test driven development

what’s up with all these tests?

Page 4: Unit testing, UI testing and Test Driven Development in Visual Studio 2012

Let’s talk about unit testing• What is Unit Testing?• What is UI Testing?• What is Test Driven Development?

Page 5: Unit testing, UI testing and Test Driven Development in Visual Studio 2012

What is a unit test?

• Code that test a single unit of functionality (obviously!)

• A single unit is any block of code that has ONE and only ONE responsibility:–Method– Function– Class

Page 6: Unit testing, UI testing and Test Driven Development in Visual Studio 2012

What is User Interface Testing?

Using unit tests to validate user interaction

Automates user actions: clicking and typing

Automated UI tests allow your machine to do repetitive tasks across an application’s interface for you ;)

Page 7: Unit testing, UI testing and Test Driven Development in Visual Studio 2012

What is Test Driven Development?

Using unit tests to design software Allows change in code without fear

of changing functionality Produces loosely coupled objects

and methods with single responsibilities

Unit tests become a tool to guide code design

Page 8: Unit testing, UI testing and Test Driven Development in Visual Studio 2012

Red Green Refactor

Page 9: Unit testing, UI testing and Test Driven Development in Visual Studio 2012

red New code

Write test before implementing class Internal workings of classes and

methods should not matter Existing code

Write test to reproduce bug

Page 10: Unit testing, UI testing and Test Driven Development in Visual Studio 2012

green Write least possible code to pass all

tests Take shortcuts if necessary

Page 11: Unit testing, UI testing and Test Driven Development in Visual Studio 2012

refactor Refactor both implementation code

and test code Change code without fear – you have

automated tests! Remove implementation shortcuts –

make sure software design makes sense

Optimize for design/performance/maintainability

Page 12: Unit testing, UI testing and Test Driven Development in Visual Studio 2012

rinse and repeat!

Page 13: Unit testing, UI testing and Test Driven Development in Visual Studio 2012

Customer feedback on MS Test

• MS Test Framework Issues–MS-Test too slow–MS-Test missing new features

• Experience Issues– Designed for testers and not for

developers– Not good for Agile & TDD

Page 14: Unit testing, UI testing and Test Driven Development in Visual Studio 2012

unit testing in visual studio 2012

what’s new

Page 15: Unit testing, UI testing and Test Driven Development in 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 16: Unit testing, UI testing and Test Driven Development in Visual Studio 2012

Yey new features!

• Developer focused user experience• MS-Test improvements• Built-in and Third-party test

frameworks• Continuous Testing• Debug Selected Tests• Code Coverage

Page 17: Unit testing, UI testing and Test Driven Development in Visual Studio 2012

Developer Focused User Experience

Red-Green Bar

Most important

tests shown first

Timings

Shows tests from any

framework

Search

Run Details

Page 18: Unit testing, UI testing and Test Driven Development in Visual Studio 2012

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!

Page 19: Unit testing, UI testing and Test Driven Development in Visual Studio 2012

Supported Test Frameworks• Built-in– .NET– Native C/C++

• Third-party– NUnit– xUnit.net–MbUnit– QUnit/Jasmine– Selenium

Page 20: Unit testing, UI testing and Test Driven Development in Visual Studio 2012

ui testing with nunit, selenium and visual studio 2012

some ui testing in the web

Page 21: Unit testing, UI testing and Test Driven Development in Visual Studio 2012

Red Green Refactor

Page 22: Unit testing, UI testing and Test Driven Development in Visual Studio 2012

test driven development with nunit and visual studio 2012

some genuine test driven development

Page 23: Unit testing, UI testing and Test Driven Development in Visual Studio 2012

Continuous Testing

• If you’re not testing you’re just compiling, not building

• Make sure you don’t break your code and tests – everytime you build!

Page 24: Unit testing, UI testing and Test Driven Development in Visual Studio 2012

Code Coverage

• 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

Page 25: Unit testing, UI testing and Test Driven Development in Visual Studio 2012

Non C# unit testing coolness

• Unit Testing Browser-based Javascript (via Qunit/Jasmine)

• Unit Testing Native C++ Applications

Page 26: Unit testing, UI testing and Test Driven Development in Visual Studio 2012

demo

let’s see it!

Page 27: Unit testing, UI testing and Test Driven Development in Visual Studio 2012

Just contact maybe :p

• twitter.com/lattex• [email protected]• dotnet.kapenilattex.com

Page 28: Unit testing, UI testing and Test Driven Development in Visual Studio 2012

References• Peter Provost:

http://channel9.msdn.com/Events/TechEd/Europe/2012/DEV214?format=html5

• Jason Zander: http://blogs.msdn.com/b/jasonz/archive/2012/05/22/my-favorite-features-unit-testing-enhancements-in-visual-studio-11.aspx

• Ben Hall: http://blog.benhall.me.uk/2008/05/nxtgenug-coventry-red-green-refactor.html

• Anoop Shetty: http://anoopjshetty.wordpress.com/2012/02/08/creating-test-automation-framework-using-c-selenium-and-nunit/