Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

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

  • 5,514 views
Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
5,514
On Slideshare
4,635
From Embeds
879
Number of Embeds
7

Actions

Shares
Downloads
55
Comments
0
Likes
0

Embeds 879

http://dotnet.kapenilattex.com 863
http://www.linkedin.com 6
http://abtasty.com 4
http://translate.googleusercontent.com 2
https://www.linkedin.com 2
http://hsmaker.com 1
https://www.google.ae 1

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • Hi my name is Jon Limjap, I’m a Microsoft Most Valuable Professional for C#,
  • This afternoon I’m going to discuss about unit testing, test driven development, C# and the new unit testing features of Visual Studio 2012
  • Ask the audience these questions:How do they define unit testing?Do they use unit testing at work?How do they define test-driven development?Do they use test driven development at work?
  • Unit testing is all about object oriented programmingTest driven development was designed to keep you from overdesigning and overcomplicating your API
  • RedNew codeWrite test before implementing classInternal workings of classes and methods should not matterExisting codeWrite test to reproduce bugGreenWrite least possible code to pass all testsTake shortcuts if necessaryRefactorRefactor both implementation code and test codeChange code without fear – you have automated tests!Remove implementation shortcuts – make sure software design makes senseOptimize for design/performance/maintainability
  • The main problem with Visual Studio is that it couldn’t do TDD
  • Whether or not you write test-first test driven development style or test-after, the best time to write your tests is while you’re writing relevant code
  • I don’t have time to demo all of these so we’ll only demo some
  • RedNew codeWrite test before implementing classInternal workings of classes and methods should not matterExisting codeWrite test to reproduce bugGreenWrite least possible code to pass all testsTake shortcuts if necessaryRefactorRefactor both implementation code and test codeChange code without fear – you have automated tests!Remove implementation shortcuts – make sure software design makes senseOptimize for design/performance/maintainability
  • To build is to build a working product, not a broken oneThe faster we know that we broke

Transcript

  • 1. unit testing, ui testing, & test-driven development in visualstudio 2012Jon LimjapC# MVP
  • 2. Agenda• Overview of Unit Testing, UI Testing and Test Driven Development• Unit testing UI and code in Visual Studio 2012
  • 3. what’s up with all these tests? overview of unit testing, ui testing, and test driven development
  • 4. Let’s talk about unit testing• What is Unit Testing?• What is UI Testing?• What is Test Driven Development?
  • 5. 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
  • 6. 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 ;)
  • 7. What is Test DrivenDevelopment? 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
  • 8. Red Green Refactor
  • 9. red New code  Write test before implementing class  Internal workings of classes and methods should not matter Existing code  Write test to reproduce bug
  • 10. green Write least possible code to pass all tests Take shortcuts if necessary
  • 11. 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
  • 12. rinse and repeat!
  • 13. 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
  • 14. what’s new unit testing in visual studio 2012
  • 15. The Visual Studio 2012 Unit Testing experience is focused on developerswriting and running unit tests while they write their code.
  • 16. Yey new features!• Developer focused user experience• MS-Test improvements• Built-in and Third-party test frameworks• Continuous Testing• Debug Selected Tests• Code Coverage
  • 17. Developer Focused User Experience
  • 18. 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!
  • 19. Supported Test Frameworks• Built-in – .NET – Native C/C++• Third-party – NUnit – xUnit.net – MbUnit – QUnit/Jasmine – Selenium
  • 20. some ui testing in the web ui testing with nunit, selenium and visual studio 2012
  • 21. Red Green Refactor
  • 22. some genuine test driven development test driven development with nunit and visual studio 2012
  • 23. 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!
  • 24. 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
  • 25. Non C# unit testing coolness• Unit Testing Browser-based Javascript (via Qunit/Jasmine)• Unit Testing Native C++ Applications
  • 26. let’s see it! demo
  • 27. Just contact maybe :p• twitter.com/lattex• jonlimjap@gmail.com• dotnet.kapenilattex.com
  • 28. 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/cr eating-test-automation-framework-using-c-