SlideShare a Scribd company logo
JavaScript
Unit Test & Code Coverage
Premnath Thimma
Thought
A solution is only as good as your
understanding of the problem.
Thought
Why Unit Test?
• Promote better design – loose coupling
• Helps developers to write
– Testable unit
– Maintainable code
• Improves quality at unit level
Difficulties/Problems
• Lack of structure
• Function not exposed outside
• Complexity in the function ( > 10 lines )
• Tight coupling between components
Solutions from AngularJS
• Structure
– Module, Model, View, Controller, Service,
Templates, Filters
• Function not exposed outside
– Service, Factory, Constant, Value
• Complexity in the function ( > 10 lines )
– Module, Injectable Components
• Tight coupling between components
– Loose coupling with Structure, Module
Tools
• JS Libraries
– Jasmine, Qunit, Mocha
• Test Runner
– Chutzpah
• Visual Studio Plug-ins
– Chutzpah Test Adapter for the Test Explorer
– Chutzpah Test Runner Context Menu Extension
– Karma Test Adapter
Get to know Jasmine
• Supports BDD (User Story)
– Spec (describe, it)
– Nest-able Spec
• Powerful Matchers (+ Customer Matcher)
• Powerful concept like Spy
• Supported by Visual Studio
– Test Explorer (includes JS Unit Tests)
– Recognizes your changes to Unit Test
Get to know Chutzpah
• Test Runner
– Right Click and Run
– Runs automatically in Visual Studio when you
make changes to Unit Test
• Code Coverage
– From Visual Studio
– From Command Line
– Exclude and Include files using expression
– Context sensitive to File or Folder
Demo
Questions
References
• https://github.com/mmanela/chutzpah
• http://chutzpah.codeplex.com/documentation
• http://jasmine.github.io/edge/introduction.html
• https://docs.angularjs.org/guide/unit-testing

More Related Content

Similar to Unit Testing JavaScript with Jasmine

ApoorvaTiwari
ApoorvaTiwariApoorvaTiwari
ApoorvaTiwari
Apoorva Tiwari
 
Rational Team Concert Process Customization - What you can and cannot do
Rational Team Concert Process Customization - What you can and cannot doRational Team Concert Process Customization - What you can and cannot do
Rational Team Concert Process Customization - What you can and cannot do
Ralph Schoon
 
Interconnect session 1888: Rational Team Concert Process Customization: What ...
Interconnect session 1888: Rational Team Concert Process Customization: What ...Interconnect session 1888: Rational Team Concert Process Customization: What ...
Interconnect session 1888: Rational Team Concert Process Customization: What ...
Rosa Naranjo
 
Continuous test automation
Continuous test automationContinuous test automation
Continuous test automation
Macharla Pradeep
 
Episode 5 - Writing unit tests in Salesforce
Episode 5 - Writing unit tests in SalesforceEpisode 5 - Writing unit tests in Salesforce
Episode 5 - Writing unit tests in Salesforce
Jitendra Zaa
 
Skillwise Unit Testing
Skillwise Unit TestingSkillwise Unit Testing
Skillwise Unit Testing
Skillwise Group
 
Vikas_CV_Testing - Welspun - SalesForce
Vikas_CV_Testing  - Welspun - SalesForceVikas_CV_Testing  - Welspun - SalesForce
Vikas_CV_Testing - Welspun - SalesForce
Vikas Kiroula
 
Get Testing with tSQLt - SQL In The City Workshop 2014
Get Testing with tSQLt - SQL In The City Workshop 2014Get Testing with tSQLt - SQL In The City Workshop 2014
Get Testing with tSQLt - SQL In The City Workshop 2014
Red Gate Software
 
Agile testing
Agile testingAgile testing
Agile testing
Raj Indugula
 
Presentation delex
Presentation delexPresentation delex
Presentation delex
Alexander Pushkarev
 
Test driven development v1.0
Test driven development v1.0Test driven development v1.0
Test driven development v1.0
Ganesh Kondal
 
Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql se...
Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql se...Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql se...
Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql se...
Codecamp Romania
 
SF1 - Apex Development Best Practises
SF1 - Apex Development Best PractisesSF1 - Apex Development Best Practises
SF1 - Apex Development Best Practises
Sebastian Wagner
 
Leveraging HP Performance Center
Leveraging HP Performance CenterLeveraging HP Performance Center
Leveraging HP Performance Center
Martin Spier
 
Sledgehammer to Fine Brush for QA
Sledgehammer to Fine Brush for QASledgehammer to Fine Brush for QA
Sledgehammer to Fine Brush for QA
Shelley Lambert
 
Battle for Code Quality - A Story of One Java Project
Battle for Code Quality - A Story of One Java ProjectBattle for Code Quality - A Story of One Java Project
Battle for Code Quality - A Story of One Java Project
GlobalLogic Ukraine
 
Sunil sharanappa senior automation test engineer profile
Sunil sharanappa senior automation test engineer profileSunil sharanappa senior automation test engineer profile
Sunil sharanappa senior automation test engineer profile
Sunil Sharanappa
 
Test Automation - Presented by Nagarajan, Architect @ TechCafe-2014
Test Automation - Presented by Nagarajan, Architect @ TechCafe-2014Test Automation - Presented by Nagarajan, Architect @ TechCafe-2014
Test Automation - Presented by Nagarajan, Architect @ TechCafe-2014
Neev Technologies
 
Test automation within a scrum process
Test automation within a scrum processTest automation within a scrum process
Test automation within a scrum process
Kushan Shalindra Amarasiri - Technical QE Specialist
 
Test Automation Architecture That Works by Bhupesh Dahal
Test Automation Architecture That Works by Bhupesh DahalTest Automation Architecture That Works by Bhupesh Dahal
Test Automation Architecture That Works by Bhupesh Dahal
QA or the Highway
 

Similar to Unit Testing JavaScript with Jasmine (20)

ApoorvaTiwari
ApoorvaTiwariApoorvaTiwari
ApoorvaTiwari
 
Rational Team Concert Process Customization - What you can and cannot do
Rational Team Concert Process Customization - What you can and cannot doRational Team Concert Process Customization - What you can and cannot do
Rational Team Concert Process Customization - What you can and cannot do
 
Interconnect session 1888: Rational Team Concert Process Customization: What ...
Interconnect session 1888: Rational Team Concert Process Customization: What ...Interconnect session 1888: Rational Team Concert Process Customization: What ...
Interconnect session 1888: Rational Team Concert Process Customization: What ...
 
Continuous test automation
Continuous test automationContinuous test automation
Continuous test automation
 
Episode 5 - Writing unit tests in Salesforce
Episode 5 - Writing unit tests in SalesforceEpisode 5 - Writing unit tests in Salesforce
Episode 5 - Writing unit tests in Salesforce
 
Skillwise Unit Testing
Skillwise Unit TestingSkillwise Unit Testing
Skillwise Unit Testing
 
Vikas_CV_Testing - Welspun - SalesForce
Vikas_CV_Testing  - Welspun - SalesForceVikas_CV_Testing  - Welspun - SalesForce
Vikas_CV_Testing - Welspun - SalesForce
 
Get Testing with tSQLt - SQL In The City Workshop 2014
Get Testing with tSQLt - SQL In The City Workshop 2014Get Testing with tSQLt - SQL In The City Workshop 2014
Get Testing with tSQLt - SQL In The City Workshop 2014
 
Agile testing
Agile testingAgile testing
Agile testing
 
Presentation delex
Presentation delexPresentation delex
Presentation delex
 
Test driven development v1.0
Test driven development v1.0Test driven development v1.0
Test driven development v1.0
 
Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql se...
Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql se...Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql se...
Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql se...
 
SF1 - Apex Development Best Practises
SF1 - Apex Development Best PractisesSF1 - Apex Development Best Practises
SF1 - Apex Development Best Practises
 
Leveraging HP Performance Center
Leveraging HP Performance CenterLeveraging HP Performance Center
Leveraging HP Performance Center
 
Sledgehammer to Fine Brush for QA
Sledgehammer to Fine Brush for QASledgehammer to Fine Brush for QA
Sledgehammer to Fine Brush for QA
 
Battle for Code Quality - A Story of One Java Project
Battle for Code Quality - A Story of One Java ProjectBattle for Code Quality - A Story of One Java Project
Battle for Code Quality - A Story of One Java Project
 
Sunil sharanappa senior automation test engineer profile
Sunil sharanappa senior automation test engineer profileSunil sharanappa senior automation test engineer profile
Sunil sharanappa senior automation test engineer profile
 
Test Automation - Presented by Nagarajan, Architect @ TechCafe-2014
Test Automation - Presented by Nagarajan, Architect @ TechCafe-2014Test Automation - Presented by Nagarajan, Architect @ TechCafe-2014
Test Automation - Presented by Nagarajan, Architect @ TechCafe-2014
 
Test automation within a scrum process
Test automation within a scrum processTest automation within a scrum process
Test automation within a scrum process
 
Test Automation Architecture That Works by Bhupesh Dahal
Test Automation Architecture That Works by Bhupesh DahalTest Automation Architecture That Works by Bhupesh Dahal
Test Automation Architecture That Works by Bhupesh Dahal
 

Recently uploaded

introduction to solar energy for engineering.pdf
introduction to solar energy for engineering.pdfintroduction to solar energy for engineering.pdf
introduction to solar energy for engineering.pdf
ravindarpurohit26
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
gerogepatton
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
gestioneergodomus
 
Building Electrical System Design & Installation
Building Electrical System Design & InstallationBuilding Electrical System Design & Installation
Building Electrical System Design & Installation
symbo111
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
Divyam548318
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
This is my Environmental physics presentation
This is my Environmental physics presentationThis is my Environmental physics presentation
This is my Environmental physics presentation
ZainabHashmi17
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
nooriasukmaningtyas
 
Low power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniquesLow power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniques
nooriasukmaningtyas
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
jpsjournal1
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Soumen Santra
 
Exception Handling notes in java exception
Exception Handling notes in java exceptionException Handling notes in java exception
Exception Handling notes in java exception
Ratnakar Mikkili
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
yokeleetan1
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
anoopmanoharan2
 
Series of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.pptSeries of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.ppt
PauloRodrigues104553
 
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.pptPROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
bhadouriyakaku
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 

Recently uploaded (20)

introduction to solar energy for engineering.pdf
introduction to solar energy for engineering.pdfintroduction to solar energy for engineering.pdf
introduction to solar energy for engineering.pdf
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
 
Building Electrical System Design & Installation
Building Electrical System Design & InstallationBuilding Electrical System Design & Installation
Building Electrical System Design & Installation
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
This is my Environmental physics presentation
This is my Environmental physics presentationThis is my Environmental physics presentation
This is my Environmental physics presentation
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
 
Low power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniquesLow power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniques
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
 
Exception Handling notes in java exception
Exception Handling notes in java exceptionException Handling notes in java exception
Exception Handling notes in java exception
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
 
Series of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.pptSeries of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.ppt
 
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.pptPROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 

Unit Testing JavaScript with Jasmine

  • 1. JavaScript Unit Test & Code Coverage Premnath Thimma
  • 2. Thought A solution is only as good as your understanding of the problem.
  • 4. Why Unit Test? • Promote better design – loose coupling • Helps developers to write – Testable unit – Maintainable code • Improves quality at unit level
  • 5. Difficulties/Problems • Lack of structure • Function not exposed outside • Complexity in the function ( > 10 lines ) • Tight coupling between components
  • 6. Solutions from AngularJS • Structure – Module, Model, View, Controller, Service, Templates, Filters • Function not exposed outside – Service, Factory, Constant, Value • Complexity in the function ( > 10 lines ) – Module, Injectable Components • Tight coupling between components – Loose coupling with Structure, Module
  • 7. Tools • JS Libraries – Jasmine, Qunit, Mocha • Test Runner – Chutzpah • Visual Studio Plug-ins – Chutzpah Test Adapter for the Test Explorer – Chutzpah Test Runner Context Menu Extension – Karma Test Adapter
  • 8. Get to know Jasmine • Supports BDD (User Story) – Spec (describe, it) – Nest-able Spec • Powerful Matchers (+ Customer Matcher) • Powerful concept like Spy • Supported by Visual Studio – Test Explorer (includes JS Unit Tests) – Recognizes your changes to Unit Test
  • 9. Get to know Chutzpah • Test Runner – Right Click and Run – Runs automatically in Visual Studio when you make changes to Unit Test • Code Coverage – From Visual Studio – From Command Line – Exclude and Include files using expression – Context sensitive to File or Folder
  • 10. Demo
  • 12. References • https://github.com/mmanela/chutzpah • http://chutzpah.codeplex.com/documentation • http://jasmine.github.io/edge/introduction.html • https://docs.angularjs.org/guide/unit-testing