SlideShare a Scribd company logo
1 of 17
Unit Testing and Test Driven Development Using VS 2010 Abhimanyu Singhal Lead Consultant iMentor Knowledge Services
Introduce Unit Testing Features How to create Team Test unit tests. Generating the unit test method stubs for an assembly Using a test driven development (TDD) Objectives
Thinking about tests pushes developer to understand better the gathered requirements Reduces the over engineered code (dead code) Unit Tests help to check that any new modification wont break the existing features. TDD increases software flexibility TDD code is more decoupled Why is TDD Good
A Visual Studio integrated unit-testing framework Code generation of test method stubs.  Running tests within the IDE.  Incorporation of test data loaded from a database.  Code coverage analysis once the tests have run.  Visual Studio Team Test
Designates a Method as a Test Method Found in Microsoft.VisualStudio.QualityTools.UnitTesting.Framework Namespace TestMethod has to be an instance method with no paramters Method name is irrelevant because reflection searches for TestMethod Attribute TestMethodAttribute Class
Class containing the test method is designated TestClass Attribute ,[object Object]
Team Test Uses Reflection to find Class with TestClass Attribute and Method with TestMethod Attribute and runs itTestClassAttribute Class
From Visual Studio As Part of Build Process From Command Line Running and Executing Tests
Takes a Parameter which is Exception Type to watch for If Exception does not occur test fails The Second parameter (string) is optional is the error message displayed when exception is not thrown ExpectedException Attribute
Use Test Properties Window Add TestData Attribute Source Type Connection String TableName DataAccessMethod Loading Test Data From Database
Provides associated data through  DataRow Property TestDirectory, TestName Mesuring Test Time using  BeingTimer()  EndTimer() The TestContext
Determines how much code is tested Shows Percentage of Code Executed Highlights code to show which lines are executed Code Coverage
TestInitialize Attribute TestCleanup Attribute Code to be run before and after each test method Other Attributes for Lifetime Methods AssemblyInitializeAttribute/AssemblyCleanupAttribute ClassInitializeAttribute/ClassCleanupAttribute. Initializing and Cleaning Up Tests
The Testing Framework
Keep Testing Code in Separate Assemblies Check for cleanup during test setup and execute the cleanup prior to the setup as necessary Avoid creating dependencies between tests, each test should be autonomous.  Create one test class corresponding to each class within the production code. Avoid creating other machine dependent tests Create mock objects to test interfaces Guidance – Unit Testing
To update the attendance for the session and obtain learning credits log on to https://ch1workspaces/sites/SW23/MS_Course_nominations/default.aspx Question and Answers Session
Thank You abhimanyu@imentor.co.in @abhi_singhal http://www.imentor.co.in/blog

More Related Content

What's hot

Moq presentation
Moq presentationMoq presentation
Moq presentation
LynxStar
 

What's hot (20)

Embrace Unit Testing
Embrace Unit TestingEmbrace Unit Testing
Embrace Unit Testing
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
Unit test
Unit testUnit test
Unit test
 
NUnit Features Presentation
NUnit Features PresentationNUnit Features Presentation
NUnit Features Presentation
 
TDD with Visual Studio 2010
TDD with Visual Studio 2010TDD with Visual Studio 2010
TDD with Visual Studio 2010
 
RIA 05 - Unit Testing by Ajinkya Prabhune
RIA 05 - Unit Testing by Ajinkya PrabhuneRIA 05 - Unit Testing by Ajinkya Prabhune
RIA 05 - Unit Testing by Ajinkya Prabhune
 
Unit and integration Testing
Unit and integration TestingUnit and integration Testing
Unit and integration Testing
 
Nguyenvandungb seminar
Nguyenvandungb seminarNguyenvandungb seminar
Nguyenvandungb seminar
 
Moq presentation
Moq presentationMoq presentation
Moq presentation
 
Test driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + EclipseTest driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + Eclipse
 
Workshop unit test
Workshop   unit testWorkshop   unit test
Workshop unit test
 
Unit Testing Concepts and Best Practices
Unit Testing Concepts and Best PracticesUnit Testing Concepts and Best Practices
Unit Testing Concepts and Best Practices
 
Testing and Mocking Object - The Art of Mocking.
Testing and Mocking Object - The Art of Mocking.Testing and Mocking Object - The Art of Mocking.
Testing and Mocking Object - The Art of Mocking.
 
Unit tests & TDD
Unit tests & TDDUnit tests & TDD
Unit tests & TDD
 
Unit tests and TDD
Unit tests and TDDUnit tests and TDD
Unit tests and TDD
 
Unit testing
Unit testingUnit testing
Unit testing
 
Unit Testing (C#)
Unit Testing (C#)Unit Testing (C#)
Unit Testing (C#)
 
Automated Unit Testing
Automated Unit TestingAutomated Unit Testing
Automated Unit Testing
 
Best practices unit testing
Best practices unit testing Best practices unit testing
Best practices unit testing
 
Intro To Unit and integration Testing
Intro To Unit and integration TestingIntro To Unit and integration Testing
Intro To Unit and integration Testing
 

Viewers also liked (14)

How to do research in today’s digital environment
How to do research in today’s digital environmentHow to do research in today’s digital environment
How to do research in today’s digital environment
 
Quesions paper
Quesions paperQuesions paper
Quesions paper
 
Iqbal pamungkas 11131334
Iqbal pamungkas 11131334Iqbal pamungkas 11131334
Iqbal pamungkas 11131334
 
Certificate
CertificateCertificate
Certificate
 
Career Reel
Career ReelCareer Reel
Career Reel
 
창의적발상22
창의적발상22창의적발상22
창의적발상22
 
LORETTO LEARY
LORETTO LEARYLORETTO LEARY
LORETTO LEARY
 
Pdb resume
Pdb resumePdb resume
Pdb resume
 
아이디어2
아이디어2아이디어2
아이디어2
 
스캠퍼1
스캠퍼1스캠퍼1
스캠퍼1
 
Lead us not to Emigration
Lead us not to EmigrationLead us not to Emigration
Lead us not to Emigration
 
MZI Modulators
MZI ModulatorsMZI Modulators
MZI Modulators
 
GLI APPALTI AGGREGATI DEI COMUNI: SEMINARIO OPERATIVO
GLI APPALTI AGGREGATI DEI COMUNI: SEMINARIO OPERATIVOGLI APPALTI AGGREGATI DEI COMUNI: SEMINARIO OPERATIVO
GLI APPALTI AGGREGATI DEI COMUNI: SEMINARIO OPERATIVO
 
Wireless Weather Station monitoring System
Wireless Weather Station monitoring SystemWireless Weather Station monitoring System
Wireless Weather Station monitoring System
 

Similar to Unit testing and test driven development using vs

justin presentation upload PPT june 19
justin presentation upload PPT june 19justin presentation upload PPT june 19
justin presentation upload PPT june 19
techweb08
 
justin for ppt1 by browse button
justin for ppt1 by browse buttonjustin for ppt1 by browse button
justin for ppt1 by browse button
techweb08
 
upload ppt by browse button
upload ppt by browse buttonupload ppt by browse button
upload ppt by browse button
techweb08
 
Paper PsUpload
Paper PsUploadPaper PsUpload
Paper PsUpload
techweb08
 
justin presentation Slideshare PPT upload June 25 Final one
justin presentation Slideshare PPT upload June 25 Final onejustin presentation Slideshare PPT upload June 25 Final one
justin presentation Slideshare PPT upload June 25 Final one
techweb08
 
upload ppt1 by browse button
upload ppt1 by browse buttonupload ppt1 by browse button
upload ppt1 by browse button
techweb08
 
upload ppt by browse button
upload ppt by browse buttonupload ppt by browse button
upload ppt by browse button
techweb08
 
Justin Presentation PPT Upload June 25 adv
Justin Presentation PPT Upload June 25 advJustin Presentation PPT Upload June 25 adv
Justin Presentation PPT Upload June 25 adv
techweb08
 
justin presentation upload PPT june 25 ADVANCED
justin presentation upload PPT june 25 ADVANCEDjustin presentation upload PPT june 25 ADVANCED
justin presentation upload PPT june 25 ADVANCED
techweb08
 
justin presentation slideshare1
justin presentation slideshare1justin presentation slideshare1
justin presentation slideshare1
techweb08
 
alka ppt test from13
alka ppt test from13 alka ppt test from13
alka ppt test from13
techweb08
 
alka ppt upload no code change
alka ppt upload no code changealka ppt upload no code change
alka ppt upload no code change
techweb08
 

Similar to Unit testing and test driven development using vs (20)

Unit Testing in Java
Unit Testing in JavaUnit Testing in Java
Unit Testing in Java
 
Paper CS
Paper CSPaper CS
Paper CS
 
alkatest7
alkatest7alkatest7
alkatest7
 
justin presentation upload PPT june 19
justin presentation upload PPT june 19justin presentation upload PPT june 19
justin presentation upload PPT june 19
 
justin for ppt1 by browse button
justin for ppt1 by browse buttonjustin for ppt1 by browse button
justin for ppt1 by browse button
 
Paper Ps
Paper PsPaper Ps
Paper Ps
 
upload ppt by browse button
upload ppt by browse buttonupload ppt by browse button
upload ppt by browse button
 
Paper PsUpload
Paper PsUploadPaper PsUpload
Paper PsUpload
 
justin presentation Slideshare PPT upload June 25 Final one
justin presentation Slideshare PPT upload June 25 Final onejustin presentation Slideshare PPT upload June 25 Final one
justin presentation Slideshare PPT upload June 25 Final one
 
Paper Ps
Paper PsPaper Ps
Paper Ps
 
upload ppt1 by browse button
upload ppt1 by browse buttonupload ppt1 by browse button
upload ppt1 by browse button
 
Paper Ps
Paper PsPaper Ps
Paper Ps
 
Paper Ps
Paper PsPaper Ps
Paper Ps
 
upload ppt by browse button
upload ppt by browse buttonupload ppt by browse button
upload ppt by browse button
 
Justin Presentation PPT Upload June 25 adv
Justin Presentation PPT Upload June 25 advJustin Presentation PPT Upload June 25 adv
Justin Presentation PPT Upload June 25 adv
 
justin presentation upload PPT june 25 ADVANCED
justin presentation upload PPT june 25 ADVANCEDjustin presentation upload PPT june 25 ADVANCED
justin presentation upload PPT june 25 ADVANCED
 
justin presentation slideshare1
justin presentation slideshare1justin presentation slideshare1
justin presentation slideshare1
 
alka ppt test from13
alka ppt test from13 alka ppt test from13
alka ppt test from13
 
alka ppt upload no code change
alka ppt upload no code changealka ppt upload no code change
alka ppt upload no code change
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 

More from Abhimanyu Singhal

Unit testing with visual studio 2012
Unit testing with visual studio 2012Unit testing with visual studio 2012
Unit testing with visual studio 2012
Abhimanyu Singhal
 
Project management with team foundation server 11
Project management with team foundation server 11Project management with team foundation server 11
Project management with team foundation server 11
Abhimanyu Singhal
 

More from Abhimanyu Singhal (15)

ASP.NET Core
ASP.NET CoreASP.NET Core
ASP.NET Core
 
Containerization with Microsoft Azure
Containerization with Microsoft AzureContainerization with Microsoft Azure
Containerization with Microsoft Azure
 
Azure Functions & Serverless Computing
Azure Functions & Serverless ComputingAzure Functions & Serverless Computing
Azure Functions & Serverless Computing
 
Mobile devops
Mobile devopsMobile devops
Mobile devops
 
Opportunity: Data, Analytic & Azure
Opportunity: Data, Analytic & Azure Opportunity: Data, Analytic & Azure
Opportunity: Data, Analytic & Azure
 
Using Specflow for BDD
Using Specflow for BDDUsing Specflow for BDD
Using Specflow for BDD
 
Behavior Driven Development
Behavior Driven DevelopmentBehavior Driven Development
Behavior Driven Development
 
Unit testing with visual studio 2012
Unit testing with visual studio 2012Unit testing with visual studio 2012
Unit testing with visual studio 2012
 
Exploratory testing
Exploratory testingExploratory testing
Exploratory testing
 
Project management with team foundation server 11
Project management with team foundation server 11Project management with team foundation server 11
Project management with team foundation server 11
 
Coded ui test
Coded ui testCoded ui test
Coded ui test
 
Visual Studio ALM
Visual Studio ALMVisual Studio ALM
Visual Studio ALM
 
Debugging application using visual studio 2010 and intellitrace
Debugging application using visual studio 2010 and intellitraceDebugging application using visual studio 2010 and intellitrace
Debugging application using visual studio 2010 and intellitrace
 
Web and load testing with Visual Studio 2010 Ultimate
Web and load testing with Visual Studio 2010 UltimateWeb and load testing with Visual Studio 2010 Ultimate
Web and load testing with Visual Studio 2010 Ultimate
 
Database development with visual studio 2010
Database development with visual studio 2010Database development with visual studio 2010
Database development with visual studio 2010
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 

Unit testing and test driven development using vs

  • 1. Unit Testing and Test Driven Development Using VS 2010 Abhimanyu Singhal Lead Consultant iMentor Knowledge Services
  • 2. Introduce Unit Testing Features How to create Team Test unit tests. Generating the unit test method stubs for an assembly Using a test driven development (TDD) Objectives
  • 3. Thinking about tests pushes developer to understand better the gathered requirements Reduces the over engineered code (dead code) Unit Tests help to check that any new modification wont break the existing features. TDD increases software flexibility TDD code is more decoupled Why is TDD Good
  • 4. A Visual Studio integrated unit-testing framework Code generation of test method stubs. Running tests within the IDE. Incorporation of test data loaded from a database. Code coverage analysis once the tests have run. Visual Studio Team Test
  • 5. Designates a Method as a Test Method Found in Microsoft.VisualStudio.QualityTools.UnitTesting.Framework Namespace TestMethod has to be an instance method with no paramters Method name is irrelevant because reflection searches for TestMethod Attribute TestMethodAttribute Class
  • 6.
  • 7. Team Test Uses Reflection to find Class with TestClass Attribute and Method with TestMethod Attribute and runs itTestClassAttribute Class
  • 8. From Visual Studio As Part of Build Process From Command Line Running and Executing Tests
  • 9. Takes a Parameter which is Exception Type to watch for If Exception does not occur test fails The Second parameter (string) is optional is the error message displayed when exception is not thrown ExpectedException Attribute
  • 10. Use Test Properties Window Add TestData Attribute Source Type Connection String TableName DataAccessMethod Loading Test Data From Database
  • 11. Provides associated data through DataRow Property TestDirectory, TestName Mesuring Test Time using BeingTimer() EndTimer() The TestContext
  • 12. Determines how much code is tested Shows Percentage of Code Executed Highlights code to show which lines are executed Code Coverage
  • 13. TestInitialize Attribute TestCleanup Attribute Code to be run before and after each test method Other Attributes for Lifetime Methods AssemblyInitializeAttribute/AssemblyCleanupAttribute ClassInitializeAttribute/ClassCleanupAttribute. Initializing and Cleaning Up Tests
  • 15. Keep Testing Code in Separate Assemblies Check for cleanup during test setup and execute the cleanup prior to the setup as necessary Avoid creating dependencies between tests, each test should be autonomous. Create one test class corresponding to each class within the production code. Avoid creating other machine dependent tests Create mock objects to test interfaces Guidance – Unit Testing
  • 16. To update the attendance for the session and obtain learning credits log on to https://ch1workspaces/sites/SW23/MS_Course_nominations/default.aspx Question and Answers Session
  • 17. Thank You abhimanyu@imentor.co.in @abhi_singhal http://www.imentor.co.in/blog