Upload
jon-limjap
View
5.445
Download
0
Embed Size (px)
DESCRIPTION
Citation preview
unit testing, ui testing, & test-driven development in visual studio 2012
Jon LimjapC# MVP
Agenda
• Overview of Unit Testing, UI Testing and Test Driven Development
• Unit testing UI and code in Visual Studio 2012
overview of unit testing, ui testing, and test driven development
what’s up with all these tests?
Let’s talk about unit testing• What is Unit Testing?• What is UI Testing?• What is Test Driven Development?
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
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 ;)
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
Red Green Refactor
red New code
Write test before implementing class Internal workings of classes and
methods should not matter Existing code
Write test to reproduce bug
green Write least possible code to pass all
tests Take shortcuts if necessary
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
rinse and repeat!
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
unit testing in visual studio 2012
what’s new
The Visual Studio 2012 Unit Testing experience is
focused on developers writing and running unit
tests while they write their code.
Yey new features!
• Developer focused user experience• MS-Test improvements• Built-in and Third-party test
frameworks• Continuous Testing• Debug Selected Tests• Code Coverage
Developer Focused User Experience
Red-Green Bar
Most important
tests shown first
Timings
Shows tests from any
framework
Search
Run Details
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!
Supported Test Frameworks• Built-in– .NET– Native C/C++
• Third-party– NUnit– xUnit.net–MbUnit– QUnit/Jasmine– Selenium
ui testing with nunit, selenium and visual studio 2012
some ui testing in the web
Red Green Refactor
test driven development with nunit and visual studio 2012
some genuine test driven development
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!
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
Non C# unit testing coolness
• Unit Testing Browser-based Javascript (via Qunit/Jasmine)
• Unit Testing Native C++ Applications
demo
let’s see it!
Just contact maybe :p
• twitter.com/lattex• [email protected]• dotnet.kapenilattex.com
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/