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 (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

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 environmentIryna Kuchma
 
Quesions paper
Quesions paperQuesions paper
Quesions paperbablup
 
Iqbal pamungkas 11131334
Iqbal pamungkas 11131334Iqbal pamungkas 11131334
Iqbal pamungkas 11131334IQBAL PAMUNGKAS
 
Career Reel
Career ReelCareer Reel
Career Reelmmarineg
 
스캠퍼1
스캠퍼1스캠퍼1
스캠퍼1ohj4321
 
Lead us not to Emigration
Lead us not to EmigrationLead us not to Emigration
Lead us not to EmigrationLoretto Leary
 
MZI Modulators
MZI ModulatorsMZI Modulators
MZI ModulatorsSuresh Jat
 
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 OPERATIVOForum Appalti
 
Wireless Weather Station monitoring System
Wireless Weather Station monitoring SystemWireless Weather Station monitoring System
Wireless Weather Station monitoring SystemAlameluPriyadharshini
 

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 19techweb08
 
justin for ppt1 by browse button
justin for ppt1 by browse buttonjustin for ppt1 by browse button
justin for ppt1 by browse buttontechweb08
 
upload ppt by browse button
upload ppt by browse buttonupload ppt by browse button
upload ppt by browse buttontechweb08
 
Paper PsUpload
Paper PsUploadPaper PsUpload
Paper PsUploadtechweb08
 
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 onetechweb08
 
upload ppt1 by browse button
upload ppt1 by browse buttonupload ppt1 by browse button
upload ppt1 by browse buttontechweb08
 
upload ppt by browse button
upload ppt by browse buttonupload ppt by browse button
upload ppt by browse buttontechweb08
 
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 advtechweb08
 
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 ADVANCEDtechweb08
 
justin presentation slideshare1
justin presentation slideshare1justin presentation slideshare1
justin presentation slideshare1techweb08
 
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 changetechweb08
 

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

Containerization with Microsoft Azure
Containerization with Microsoft AzureContainerization with Microsoft Azure
Containerization with Microsoft AzureAbhimanyu Singhal
 
Azure Functions & Serverless Computing
Azure Functions & Serverless ComputingAzure Functions & Serverless Computing
Azure Functions & Serverless ComputingAbhimanyu Singhal
 
Opportunity: Data, Analytic & Azure
Opportunity: Data, Analytic & Azure Opportunity: Data, Analytic & Azure
Opportunity: Data, Analytic & Azure Abhimanyu Singhal
 
Unit testing with visual studio 2012
Unit testing with visual studio 2012Unit testing with visual studio 2012
Unit testing with visual studio 2012Abhimanyu 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 11Abhimanyu Singhal
 
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 intellitraceAbhimanyu Singhal
 
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 UltimateAbhimanyu Singhal
 
Database development with visual studio 2010
Database development with visual studio 2010Database development with visual studio 2010
Database development with visual studio 2010Abhimanyu 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

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
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 challengesrafiqahmad00786416
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
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 DiscoveryTrustArc
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
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...DianaGray10
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
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.pdfOrbitshub
 
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.pptxRemote DBA Services
 

Recently uploaded (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
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
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
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
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
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...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
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
 
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
 

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