SlideShare ist ein Scribd-Unternehmen logo
1 von 40
Boutique product development company
It is amazing what you can accomplish when you have a client-centric team to deliver outstanding products.
Boutique product development company
It is amazing what you can accomplish when you have a client-centric team to deliver outstanding products.
Unit Testing, Test Driven Development
and JavaScript Testing Frameworks
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
Unit Testing increases the code quality
Unit Testing, TDD and
JavaScript Testing
Frameworks
Testing Types
Overview of Unit Testing
Best Practices
Some Difficult Scenarios
Levels of TDD
Test Driven Development
TDD and Agile
Extreme Programming
Comparison of available JS Testing frameworks
Introduction to Jasmine Framework
Examples
Jasmine Framework practical's
Karma Framework practical’s
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
WHY Unit Testing
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
Types of Tests
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
Overview
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
What is Unit Test
–Verifies an atomic piece of code
–Test on specific behavior
–Each test is autonomous
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
Why Unit Testing
Consider building a car
from start to finish,
each of the parts which
make the engine, the
chassis, the wheels,
must be individually
verified to be in working
order before they are to
be assembled into a
'car'.
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
Unit Tests are written by developers!
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
 Increase confidence in code
 Fearlessly change your code
 Discover usability issues early
Test is not a Unit if
Interact over parts of system.
Take too much time to execute (>0.01 Sec).
Require Manual Setup.
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
Unit Test Best Practices
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
1. Consistent
2. Atomic
3. Single Responsibility
4. Self Descriptive
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
Single Responsibility
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
1. One condition per test
2. One reason to change
Unit Test Best Practices
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
Difficult Scenarios
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
Difficult Scenarios
Continue..
– Mocks
– Stubs
– Fake
Levels of TDD
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
– Acceptance TDD(ATDD)
– Developer TDD
Test Driven Development
•Write Test
•Fail the test
•Write Minimum Code
•Pass the test
•Re factor Code
•Meet standards
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
Why Test Driven Development
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
TDD is not about Testing
TDD is about
–Design and Development
•By testing first you design your code
Unit Testing and TDD
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
Rules for Extreme Programming
1. User stories (planning)
2. Small releases
3. Metaphor (standardized naming schemes)
4. Collective ownership
5. Coding standard:
6. Simple design
7. Refactoring
8. TDD
9. Pair programming
10.Continuous integration
11.40-hour workweek
12.On-site customer
XP– Contd.
Comparison of JS Unit Testing Frameworks
Framework Suitable for
Direct access to
JavaScript DOM API
Remote
control
File
watching
File
preprocessing
Tests written
in
Karma
unit yes yes yes yes yes any
JSTestDriver
unit yes yes yes no no JS
Selenium
e2e no yes yes no no any
WebDriver
e2e no yes yes no no any
Jasmine
unit yes yes no no no JS
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
Jasmine Framework
• Jasmine is a behavior-driven development framework for testing your JavaScript
code. It does not depend on any other JavaScript frameworks. It does not require a
DOM.
Jasmine API includes features such as:
• A more natural BDD syntax for organizing the test logic than JUnit style assertion
test frameworks
• Asynchronous testing
• Mocks
• Easy to create custom matchers
• Ability to share or isolate behaviors between tests within a spec encapsulating parts
of your spec.
• Continuous integration support
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
Jasmine Framework: Syntax
Jasmine aims to be easy to read. A simple hello world test looks like this:
describe('Hello world', function() {
it('says hello', function() {
expect(helloWorld()).toEqual("Hello world!");
});
});
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
Jasmine Framework: Test Suite and Test Cases
describe('MyApp Test Suite:', function() { });
• The above “Describe” block defines the test suite in Jasmine, in test suite
single or multiple test cases can be written.
it('Should contain no JavaScript coding errors!', function() {
expect(errorCount).toBe(0); });
• This above “It” block is representing the test cases which can written in
Describe block. Expect showing the expected result for the particular test case.
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
Example
Example
Jasmine Framework: Spec and JS Code
A Jasmine test case is written as follows:
// your applications custom code
function addValues( a, b )
{ return a + b; };
// the Jasmine test code
describe("addValues(a, b) function", function() {
it("should equal 3", function(){
expect( addValues(1, 2) ).toBe( 3 ); });
it("should equal 3.75", function(){
expect( addValues(1.75, 2) ).toBe( 3.75 ); });
it("should NOT equal '3' as a String", function(){
expect( addValues(1, 2) ).not.toBe( "3" ); });
});
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
Jasmine Framework: Spec Runner (Running the Unit Tests)
Launching the SpecRunner.html file in your local browser runs the tests. Jasmine
provides a nice view of the test results.
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
Jasmine Framework: Pros and Cons
Pros:
• Should not be tied to any browser, framework, platform, or host language.
• Should have idiomatic and unsurprising syntax.
• Should work anywhere JavaScript can run, including browsers, servers, phones, etc.
• Shouldn't intrude in your application's territory (e.g. by cluttering the global
namespace).
• Should play well with IDEs (e.g. test code should pass static analysis).
• It should integrate easily with continuous build systems.
• It should be simple to get started with.
Cons:
Not Much examples available
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
Basic general test cases
Rainy Days
Sencha Project unit tests
Karma Practical App – ToDo App
Practical Example
Jasmine can Use with
• Ruby (with or without Rails)
• Spider Monkey
• Node.js
• JS Test Driver
• Java (with Maven)
• DOT NET
• PERL
• Scala
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
Testing in Angular JS
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
References
http://evanhahn.com/how-do-i-jasmine/
http://pivotal.github.io/jasmine/
http://stackoverflow.com/questions/300855/javascript-unit-test-tools-for-tdd
http://docs.angularjs.org/tutorial
http://edspencer.net/2013/07/28/jasmine-and-jenkins-continuous-integration/
http://stackoverflow.com/questions/3459287/whats-the-difference-between-a-mock-
stub
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer
Q&A
Thanks for Attending
Sikandar Ahmed | Lead Software Engineer
Ahmad Awais | Software Engineer

Weitere ähnliche Inhalte

Was ist angesagt?

Ria Made Easier With Zend
Ria Made Easier With ZendRia Made Easier With Zend
Ria Made Easier With Zend
Roy Ganor
 
BDD approach with Selenium RC
BDD approach with Selenium RCBDD approach with Selenium RC
BDD approach with Selenium RC
Mykola Kolisnyk
 

Was ist angesagt? (20)

Amazon CodeGuru - Automate Code review and Code performance monitoring
Amazon CodeGuru - Automate Code review and Code performance monitoringAmazon CodeGuru - Automate Code review and Code performance monitoring
Amazon CodeGuru - Automate Code review and Code performance monitoring
 
Behaviour Driven Development
Behaviour Driven DevelopmentBehaviour Driven Development
Behaviour Driven Development
 
Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)
 
Bdd – with cucumber and gherkin
Bdd – with cucumber and gherkinBdd – with cucumber and gherkin
Bdd – with cucumber and gherkin
 
Cucumber & gherkin language
Cucumber & gherkin languageCucumber & gherkin language
Cucumber & gherkin language
 
Introduction to Bdd and cucumber
Introduction to Bdd and cucumberIntroduction to Bdd and cucumber
Introduction to Bdd and cucumber
 
PHPConf.asia 2016 - BDD with Behat for Beginners
PHPConf.asia 2016 - BDD with Behat for BeginnersPHPConf.asia 2016 - BDD with Behat for Beginners
PHPConf.asia 2016 - BDD with Behat for Beginners
 
Ria Made Easier With Zend
Ria Made Easier With ZendRia Made Easier With Zend
Ria Made Easier With Zend
 
Understanding Why Testing is Importaint
Understanding Why Testing is ImportaintUnderstanding Why Testing is Importaint
Understanding Why Testing is Importaint
 
What Is Cucumber?
What Is Cucumber?What Is Cucumber?
What Is Cucumber?
 
Behavior Driven Testing - A paradigm shift
Behavior Driven Testing - A paradigm shiftBehavior Driven Testing - A paradigm shift
Behavior Driven Testing - A paradigm shift
 
Test Automation Framework with BDD and Cucumber
Test Automation Framework with BDD and CucumberTest Automation Framework with BDD and Cucumber
Test Automation Framework with BDD and Cucumber
 
BDD approach with Selenium RC
BDD approach with Selenium RCBDD approach with Selenium RC
BDD approach with Selenium RC
 
Behavior Driven Development - TdT@Cluj #15
Behavior Driven Development - TdT@Cluj #15Behavior Driven Development - TdT@Cluj #15
Behavior Driven Development - TdT@Cluj #15
 
Bdd and spec flow
Bdd and spec flowBdd and spec flow
Bdd and spec flow
 
Bdd in action
Bdd in actionBdd in action
Bdd in action
 
Testing with cucumber testing framework
Testing with cucumber testing frameworkTesting with cucumber testing framework
Testing with cucumber testing framework
 
Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)
 
Cypress test techniques cucumber bdd framework,tdd,api tests course
Cypress test techniques cucumber bdd framework,tdd,api tests courseCypress test techniques cucumber bdd framework,tdd,api tests course
Cypress test techniques cucumber bdd framework,tdd,api tests course
 
Cypress Test Techniques-Cucumber BDD Framework,TDD,API Tests
Cypress Test Techniques-Cucumber BDD Framework,TDD,API TestsCypress Test Techniques-Cucumber BDD Framework,TDD,API Tests
Cypress Test Techniques-Cucumber BDD Framework,TDD,API Tests
 

Andere mochten auch

Slaven tomac unit testing in angular js
Slaven tomac   unit testing in angular jsSlaven tomac   unit testing in angular js
Slaven tomac unit testing in angular js
Slaven Tomac
 

Andere mochten auch (20)

Angular testing
Angular testingAngular testing
Angular testing
 
AngularJS Testing Strategies
AngularJS Testing StrategiesAngularJS Testing Strategies
AngularJS Testing Strategies
 
Angular 2 - What's new and what's different
Angular 2 - What's new and what's differentAngular 2 - What's new and what's different
Angular 2 - What's new and what's different
 
Unit testing JavaScript: Jasmine & karma intro
Unit testing JavaScript: Jasmine & karma introUnit testing JavaScript: Jasmine & karma intro
Unit testing JavaScript: Jasmine & karma intro
 
JavaScript TDD with Jasmine and Karma
JavaScript TDD with Jasmine and KarmaJavaScript TDD with Jasmine and Karma
JavaScript TDD with Jasmine and Karma
 
Javascript Tests with Jasmine for Front-end Devs
Javascript Tests with Jasmine for Front-end DevsJavascript Tests with Jasmine for Front-end Devs
Javascript Tests with Jasmine for Front-end Devs
 
Introduction to Javascript Unit Testing With xUnit.js
Introduction to Javascript Unit Testing With xUnit.jsIntroduction to Javascript Unit Testing With xUnit.js
Introduction to Javascript Unit Testing With xUnit.js
 
Testing Javascript with Jasmine
Testing Javascript with JasmineTesting Javascript with Jasmine
Testing Javascript with Jasmine
 
JavaScript Unit Testing
JavaScript Unit TestingJavaScript Unit Testing
JavaScript Unit Testing
 
Client side unit tests - using jasmine & karma
Client side unit tests - using jasmine & karmaClient side unit tests - using jasmine & karma
Client side unit tests - using jasmine & karma
 
Story about module management with angular.js
Story about module management with angular.jsStory about module management with angular.js
Story about module management with angular.js
 
EasyTest Test Automation Tool Introduction
EasyTest Test Automation Tool IntroductionEasyTest Test Automation Tool Introduction
EasyTest Test Automation Tool Introduction
 
Testing angular js
Testing angular jsTesting angular js
Testing angular js
 
Slaven tomac unit testing in angular js
Slaven tomac   unit testing in angular jsSlaven tomac   unit testing in angular js
Slaven tomac unit testing in angular js
 
Test-Driven Development with TypeScript+Jasmine+AngularJS
Test-Driven Development with TypeScript+Jasmine+AngularJSTest-Driven Development with TypeScript+Jasmine+AngularJS
Test-Driven Development with TypeScript+Jasmine+AngularJS
 
JavaScript Test-Driven Development with Jasmine 2.0 and Karma
JavaScript Test-Driven Development with Jasmine 2.0 and Karma JavaScript Test-Driven Development with Jasmine 2.0 and Karma
JavaScript Test-Driven Development with Jasmine 2.0 and Karma
 
AngularJS Testing
AngularJS TestingAngularJS Testing
AngularJS Testing
 
Test-Driven Development of AngularJS Applications
Test-Driven Development of AngularJS ApplicationsTest-Driven Development of AngularJS Applications
Test-Driven Development of AngularJS Applications
 
AngularJS Unit Test
AngularJS Unit TestAngularJS Unit Test
AngularJS Unit Test
 
Advanced Jasmine - Front-End JavaScript Unit Testing
Advanced Jasmine - Front-End JavaScript Unit TestingAdvanced Jasmine - Front-End JavaScript Unit Testing
Advanced Jasmine - Front-End JavaScript Unit Testing
 

Ähnlich wie TDD, unit testing and java script testing frameworks workshop

Angular Unit testing.pptx
Angular Unit testing.pptxAngular Unit testing.pptx
Angular Unit testing.pptx
RiyaBangera
 
UI Test Cases With CloudStack
UI Test Cases With CloudStackUI Test Cases With CloudStack
UI Test Cases With CloudStack
ShapeBlue
 

Ähnlich wie TDD, unit testing and java script testing frameworks workshop (20)

Udvid din test portefølje med coded ui test og cloud load test
Udvid din test portefølje med coded ui test og cloud load testUdvid din test portefølje med coded ui test og cloud load test
Udvid din test portefølje med coded ui test og cloud load test
 
Angular Unit testing.pptx
Angular Unit testing.pptxAngular Unit testing.pptx
Angular Unit testing.pptx
 
Azure Integration DTAP Series, How to go from Development to Production – Par...
Azure Integration DTAP Series, How to go from Development to Production – Par...Azure Integration DTAP Series, How to go from Development to Production – Par...
Azure Integration DTAP Series, How to go from Development to Production – Par...
 
Azure Integration DTAP Series, How to go from Development to Production – Par...
Azure Integration DTAP Series, How to go from Development to Production – Par...Azure Integration DTAP Series, How to go from Development to Production – Par...
Azure Integration DTAP Series, How to go from Development to Production – Par...
 
End-end tests as first class citizens - SeleniumConf 2020
End-end tests as first class citizens - SeleniumConf 2020End-end tests as first class citizens - SeleniumConf 2020
End-end tests as first class citizens - SeleniumConf 2020
 
UI Test Cases With CloudStack
UI Test Cases With CloudStackUI Test Cases With CloudStack
UI Test Cases With CloudStack
 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by Example
 
Scrum_BLR 11th meet up 13 dec-2014 - SDET - They Way to go for Testers - Jaya...
Scrum_BLR 11th meet up 13 dec-2014 - SDET - They Way to go for Testers - Jaya...Scrum_BLR 11th meet up 13 dec-2014 - SDET - They Way to go for Testers - Jaya...
Scrum_BLR 11th meet up 13 dec-2014 - SDET - They Way to go for Testers - Jaya...
 
Enter the mind of an Agile Developer
Enter the mind of an Agile DeveloperEnter the mind of an Agile Developer
Enter the mind of an Agile Developer
 
Software Quality and Test Strategies for Ruby and Rails Applications
Software Quality and Test Strategies for Ruby and Rails ApplicationsSoftware Quality and Test Strategies for Ruby and Rails Applications
Software Quality and Test Strategies for Ruby and Rails Applications
 
Meticulous Planning of Test Automation
Meticulous Planning of Test AutomationMeticulous Planning of Test Automation
Meticulous Planning of Test Automation
 
Test automation within a scrum process
Test automation within a scrum processTest automation within a scrum process
Test automation within a scrum process
 
Putting Quality First through Continuous Testing
Putting Quality First through Continuous TestingPutting Quality First through Continuous Testing
Putting Quality First through Continuous Testing
 
A journey to_be_a_software_craftsman
A journey to_be_a_software_craftsmanA journey to_be_a_software_craftsman
A journey to_be_a_software_craftsman
 
Behavior Driven Development—A Guide to Agile Practices by Josh Eastman
Behavior Driven Development—A Guide to Agile Practices by Josh EastmanBehavior Driven Development—A Guide to Agile Practices by Josh Eastman
Behavior Driven Development—A Guide to Agile Practices by Josh Eastman
 
Slides for Automation Testing or End to End testing
Slides for Automation Testing or End to End testingSlides for Automation Testing or End to End testing
Slides for Automation Testing or End to End testing
 
Test automation - Building effective solutions
Test automation - Building effective solutionsTest automation - Building effective solutions
Test automation - Building effective solutions
 
Test Driven Development and Automation
Test Driven Development and AutomationTest Driven Development and Automation
Test Driven Development and Automation
 
Acceptance Test Driven Development and Robot Framework
Acceptance Test Driven Development and Robot FrameworkAcceptance Test Driven Development and Robot Framework
Acceptance Test Driven Development and Robot Framework
 
Mobile Code Optimisation Services
Mobile Code Optimisation ServicesMobile Code Optimisation Services
Mobile Code Optimisation Services
 

Kürzlich hochgeladen

CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Kürzlich hochgeladen (20)

10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 

TDD, unit testing and java script testing frameworks workshop

  • 1. Boutique product development company It is amazing what you can accomplish when you have a client-centric team to deliver outstanding products.
  • 2. Boutique product development company It is amazing what you can accomplish when you have a client-centric team to deliver outstanding products. Unit Testing, Test Driven Development and JavaScript Testing Frameworks Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer
  • 3. Unit Testing increases the code quality Unit Testing, TDD and JavaScript Testing Frameworks Testing Types Overview of Unit Testing Best Practices Some Difficult Scenarios Levels of TDD Test Driven Development TDD and Agile Extreme Programming Comparison of available JS Testing frameworks Introduction to Jasmine Framework Examples Jasmine Framework practical's Karma Framework practical’s Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer
  • 4. WHY Unit Testing Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer
  • 5. Types of Tests Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer
  • 6. Overview Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer What is Unit Test –Verifies an atomic piece of code –Test on specific behavior –Each test is autonomous
  • 7. Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer
  • 8. Why Unit Testing Consider building a car from start to finish, each of the parts which make the engine, the chassis, the wheels, must be individually verified to be in working order before they are to be assembled into a 'car'. Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer
  • 9. Unit Tests are written by developers! Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer  Increase confidence in code  Fearlessly change your code  Discover usability issues early
  • 10. Test is not a Unit if Interact over parts of system. Take too much time to execute (>0.01 Sec). Require Manual Setup. Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer
  • 11. Unit Test Best Practices Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer 1. Consistent 2. Atomic 3. Single Responsibility 4. Self Descriptive
  • 12. Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer
  • 13. Single Responsibility Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer 1. One condition per test 2. One reason to change
  • 14. Unit Test Best Practices Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer
  • 15. Difficult Scenarios Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer
  • 18. Levels of TDD Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer – Acceptance TDD(ATDD) – Developer TDD
  • 19. Test Driven Development •Write Test •Fail the test •Write Minimum Code •Pass the test •Re factor Code •Meet standards Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer
  • 20. Why Test Driven Development Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer
  • 21. Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer TDD is not about Testing TDD is about –Design and Development •By testing first you design your code
  • 22. Unit Testing and TDD Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer
  • 23. Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer
  • 24. Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer Rules for Extreme Programming 1. User stories (planning) 2. Small releases 3. Metaphor (standardized naming schemes) 4. Collective ownership 5. Coding standard: 6. Simple design 7. Refactoring 8. TDD 9. Pair programming 10.Continuous integration 11.40-hour workweek 12.On-site customer
  • 26. Comparison of JS Unit Testing Frameworks Framework Suitable for Direct access to JavaScript DOM API Remote control File watching File preprocessing Tests written in Karma unit yes yes yes yes yes any JSTestDriver unit yes yes yes no no JS Selenium e2e no yes yes no no any WebDriver e2e no yes yes no no any Jasmine unit yes yes no no no JS Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer
  • 27. Jasmine Framework • Jasmine is a behavior-driven development framework for testing your JavaScript code. It does not depend on any other JavaScript frameworks. It does not require a DOM. Jasmine API includes features such as: • A more natural BDD syntax for organizing the test logic than JUnit style assertion test frameworks • Asynchronous testing • Mocks • Easy to create custom matchers • Ability to share or isolate behaviors between tests within a spec encapsulating parts of your spec. • Continuous integration support Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer
  • 28. Jasmine Framework: Syntax Jasmine aims to be easy to read. A simple hello world test looks like this: describe('Hello world', function() { it('says hello', function() { expect(helloWorld()).toEqual("Hello world!"); }); }); Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer
  • 29. Jasmine Framework: Test Suite and Test Cases describe('MyApp Test Suite:', function() { }); • The above “Describe” block defines the test suite in Jasmine, in test suite single or multiple test cases can be written. it('Should contain no JavaScript coding errors!', function() { expect(errorCount).toBe(0); }); • This above “It” block is representing the test cases which can written in Describe block. Expect showing the expected result for the particular test case. Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer
  • 32. Jasmine Framework: Spec and JS Code A Jasmine test case is written as follows: // your applications custom code function addValues( a, b ) { return a + b; }; // the Jasmine test code describe("addValues(a, b) function", function() { it("should equal 3", function(){ expect( addValues(1, 2) ).toBe( 3 ); }); it("should equal 3.75", function(){ expect( addValues(1.75, 2) ).toBe( 3.75 ); }); it("should NOT equal '3' as a String", function(){ expect( addValues(1, 2) ).not.toBe( "3" ); }); }); Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer
  • 33. Jasmine Framework: Spec Runner (Running the Unit Tests) Launching the SpecRunner.html file in your local browser runs the tests. Jasmine provides a nice view of the test results. Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer
  • 34. Jasmine Framework: Pros and Cons Pros: • Should not be tied to any browser, framework, platform, or host language. • Should have idiomatic and unsurprising syntax. • Should work anywhere JavaScript can run, including browsers, servers, phones, etc. • Shouldn't intrude in your application's territory (e.g. by cluttering the global namespace). • Should play well with IDEs (e.g. test code should pass static analysis). • It should integrate easily with continuous build systems. • It should be simple to get started with. Cons: Not Much examples available Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer
  • 35. Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer Basic general test cases Rainy Days Sencha Project unit tests Karma Practical App – ToDo App Practical Example
  • 36. Jasmine can Use with • Ruby (with or without Rails) • Spider Monkey • Node.js • JS Test Driver • Java (with Maven) • DOT NET • PERL • Scala Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer
  • 37. Testing in Angular JS Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer
  • 38.
  • 40. Q&A Thanks for Attending Sikandar Ahmed | Lead Software Engineer Ahmad Awais | Software Engineer