SlideShare a Scribd company logo
Test Driven Development
(TDD) using QUnit
By Satej Kumar Sahu
Mindfire Solutions
Contents
• What is TDD?
• A look into BDD
• Real life example
• TDD concepts
• What is QUnit?
• QUnit API sample use cases with examples
• TDD using unit tests with QUnit
• Conclusion
Simple Testing
• What is Testing?
• Who does it? Is it solely confined as a role of QA?
• Sometimes gives you a feeling of being Sherlock Holmes (The famous detective you know) in a
mystery.
• Some examples of simple testing may include:
- Manual browser testing
- Echo, exit testing
- Debug tools like xDebug, IDE integrated debugging, breakpoints etc.
• Pros:
- Simple, easy to debug methods and tools.
- Sometimes and in some ways are quick in showing results.
• Cons:
- Does not cover every aspect.
- Time taking and risk prone.
- Monotonous and repetitive.
- In long term, not productive.
What is TDD?
• Test Driven Development
• It’s a practice that embodies a test first methodology.
• In either real world or the virtual world, in software
industry or any other industry, TDD can / is being
followed. Building a house or a room. Seminar
planning.
• You have requirements or cases or stories for a
project. With TDD, you first start from writing test cases
for requirements and then followup with development
code to pass those test cases.
Test Driven Development using QUnit
Test Driven Development using QUnit
A look into BDD
• In contrast to TDD, BDD is when we write behaviour & specification that
then drives our software development.
• Behaviour & specification might seem awfully similar to tests but the
difference is very subtle and important.
• The main difference is just the wording. BDD uses a more verbose style so
that it can be read almost like a sentence.
• The ability to read your tests like a sentence is a cognitive shift in how you
will think about your tests. The argument is that if you can read your tests
fluidly, you will naturally write better and more comprehensive tests.
• BDD tests should be more focused on the features, not the actual results.
• https://github.com/joshuaclayton/specit
Real life example
• As the saying goes for a tailor “Measure twice, cut once”
• A Tailor -> Software Developer
• Notes the cloth requirement -> Project requirement
• Starts with measurement, prototypes using sketches,
software models -> Test cases
• Starts cutting cloth with every minute precision of
measurement being compared with tools against
specifications -> Code development and running test
cases reiteration.
TDD concepts
• Steps of TDD:
- Test first
- “Make it run”
- Refactor / Make it better.
• Refactoring: Act of restructuring, rewriting, renaming and removing code in order to improve:
- Design
- Readability
- Maintainability
• 3 A’s of Unit Testing:
- Assemble
- Act
- Assert
• Unit Test: Focus is on individual components.
• From unit tests, one can proceed on to end to end testing where focus is on complete
behaviour of a feature.
• A simple test case written using console.log
• Need of unit test frameworks for testing
• Provide tools and APIs to test.
• A framework that provides a test runner, as well
as some utilities to write the actual tests.
What is QUnit?
• QUnit is a powerful, easy-to-use JavaScript unit
testing framework.
• It's used by the jQuery, jQuery UI and jQuery
Mobile projects and is capable of testing any
generic JavaScript code, including itself!
• http://qunitjs.com/
QUnit user interface and it's
various parts.
QUnit API sample use cases
with examples
• ok( truthy [, message ] )
• equal( actual, expected [, message ] )
• strictEqual()
• deepEqual( actual, expected [, message ] )
• expect() -> testing callbacks
• async()
• QUnit.module()
TDD using unit tests
with QUnit
• Advantages:
- Your application is test covered.
- Customers, clients and developers are more
confident about their application robustness.
- Tests are automated. You just need to run it. Can
be part of a CI process.
- Productivity increases.
- You implement features and fixes without worrying
about what you have broken.
- Testing can also drive the design of software. Unit
block codes are present and are decoupled and
independent. TDD thinking helps in better API
design.
- It acts as a documentation for your application.
Some practical use cases of
QUnit
• https://github.com/jquery/jquery/tree/master/test/unit
• https://github.com/jquery/jquery-ui/tree/master/tests/unit
• https://github.com/jzaefferer/jquery-validation/tree/master/te
References
• http://hubpages.com/business/Test-First-A-Real-Life-Ex
• http://qunitjs.com/
• http://qunitjs.com/cookbook/
• http://qunitjs.com/plugins/
Conclusion
• TDD Rocks :)
Any?

More Related Content

What's hot (20)

DOCX
Automation Frame works Instruction Sheet
vodQA
 
PPTX
Better End-to-End Testing with Page Objects Model using Protractor
Kasun Kodagoda
 
PPTX
Angular Unit Testing
Shailendra Chauhan
 
PDF
AngularJS and Protractor
Filipe Falcão
 
PPTX
BDD with SpecFlow and Selenium
Liraz Shay
 
PPTX
Protractor Tutorial Quality in Agile 2015
Andrew Eisenberg
 
PDF
Gatling Performance Workshop
Sai Krishna
 
PPTX
Nightwatch JS for End to End Tests
Sriram Angajala
 
PPTX
Cypress test techniques cucumber bdd framework,tdd,api tests course
Narayanan Palani
 
PPTX
BDD for APIs
Jason Harmon
 
PPTX
Protractor training
Sergiy Stotskiy
 
PPTX
Testing of React JS app
Aleks Zinevych
 
PDF
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Codemotion
 
PDF
Acceptance Test-driven Development with Cucumber-jvm
Christopher Bartling
 
PDF
Using The Page Object Pattern
Dante Briones
 
PPTX
Angular js automation using protractor
Ravi Gupta
 
PPTX
Automated Testing using JavaScript
Simon Guest
 
PDF
Devday2016 real unittestingwithmockframework-phatvu
Phat VU
 
PDF
Codeception: introduction to php testing
Engineor
 
PDF
Workshop - E2e tests with protractor
Walmyr Lima e Silva Filho
 
Automation Frame works Instruction Sheet
vodQA
 
Better End-to-End Testing with Page Objects Model using Protractor
Kasun Kodagoda
 
Angular Unit Testing
Shailendra Chauhan
 
AngularJS and Protractor
Filipe Falcão
 
BDD with SpecFlow and Selenium
Liraz Shay
 
Protractor Tutorial Quality in Agile 2015
Andrew Eisenberg
 
Gatling Performance Workshop
Sai Krishna
 
Nightwatch JS for End to End Tests
Sriram Angajala
 
Cypress test techniques cucumber bdd framework,tdd,api tests course
Narayanan Palani
 
BDD for APIs
Jason Harmon
 
Protractor training
Sergiy Stotskiy
 
Testing of React JS app
Aleks Zinevych
 
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Codemotion
 
Acceptance Test-driven Development with Cucumber-jvm
Christopher Bartling
 
Using The Page Object Pattern
Dante Briones
 
Angular js automation using protractor
Ravi Gupta
 
Automated Testing using JavaScript
Simon Guest
 
Devday2016 real unittestingwithmockframework-phatvu
Phat VU
 
Codeception: introduction to php testing
Engineor
 
Workshop - E2e tests with protractor
Walmyr Lima e Silva Filho
 

Similar to Test Driven Development using QUnit (20)

PPTX
Understanding TDD - theory, practice, techniques and tips.
Malinda Kapuruge
 
PPTX
TDD - Seriously, try it! - Opensouthcode
Nacho Cougil
 
PPTX
Test driven development v1.0
Ganesh Kondal
 
PPTX
Ian Cooper webinar for DDD Iran: Kent beck style tdd seven years after
Iranian Domain-Driven Design Community
 
PPTX
TDD - Agile
harinderpisces
 
PPTX
TDD - Seriously, try it - Codemotion (May '24)
Nacho Cougil
 
PPTX
TDD - Seriously, try it! - Bucarest Tech Week
Nacho Cougil
 
PDF
Unit testing (eng)
Anatoliy Okhotnikov
 
PDF
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Uma Ghotikar
 
PDF
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Ortus Solutions, Corp
 
PDF
An Introduction to Test Driven Development
CodeOps Technologies LLP
 
KEY
Driving application development through behavior driven development
Einar Ingebrigtsen
 
PPTX
TDD - Seriously, try it! (updated '22)
Nacho Cougil
 
PPTX
TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)
Nacho Cougil
 
PPTX
TDD - Seriously, try it! - Trójmiasto Java User Group (17th May '23)
ssusercaf6c1
 
PPTX
Unit Testing talk
Sergei Kukharev
 
PPTX
Test driven development
Nascenia IT
 
PPTX
Test Driven Development - a Practitioner’s Perspective
Malinda Kapuruge
 
PPT
Test Driven Development - Overview and Adoption
Pyxis Technologies
 
Understanding TDD - theory, practice, techniques and tips.
Malinda Kapuruge
 
TDD - Seriously, try it! - Opensouthcode
Nacho Cougil
 
Test driven development v1.0
Ganesh Kondal
 
Ian Cooper webinar for DDD Iran: Kent beck style tdd seven years after
Iranian Domain-Driven Design Community
 
TDD - Agile
harinderpisces
 
TDD - Seriously, try it - Codemotion (May '24)
Nacho Cougil
 
TDD - Seriously, try it! - Bucarest Tech Week
Nacho Cougil
 
Unit testing (eng)
Anatoliy Okhotnikov
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Uma Ghotikar
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Ortus Solutions, Corp
 
An Introduction to Test Driven Development
CodeOps Technologies LLP
 
Driving application development through behavior driven development
Einar Ingebrigtsen
 
TDD - Seriously, try it! (updated '22)
Nacho Cougil
 
TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)
Nacho Cougil
 
TDD - Seriously, try it! - Trójmiasto Java User Group (17th May '23)
ssusercaf6c1
 
Unit Testing talk
Sergei Kukharev
 
Test driven development
Nascenia IT
 
Test Driven Development - a Practitioner’s Perspective
Malinda Kapuruge
 
Test Driven Development - Overview and Adoption
Pyxis Technologies
 
Ad

Recently uploaded (20)

PPTX
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
PPTX
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
PDF
Capcut Pro Crack For PC Latest Version {Fully Unlocked} 2025
hashhshs786
 
PPTX
3uTools Full Crack Free Version Download [Latest] 2025
muhammadgurbazkhan
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
PPT
MergeSortfbsjbjsfk sdfik k
RafishaikIT02044
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PPTX
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
PDF
Efficient, Automated Claims Processing Software for Insurers
Insurance Tech Services
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
PDF
Streamline Contractor Lifecycle- TECH EHS Solution
TECH EHS Solution
 
PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
PPTX
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
PDF
Executive Business Intelligence Dashboards
vandeslie24
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PPTX
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PPTX
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
Capcut Pro Crack For PC Latest Version {Fully Unlocked} 2025
hashhshs786
 
3uTools Full Crack Free Version Download [Latest] 2025
muhammadgurbazkhan
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
MergeSortfbsjbjsfk sdfik k
RafishaikIT02044
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
Efficient, Automated Claims Processing Software for Insurers
Insurance Tech Services
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
Streamline Contractor Lifecycle- TECH EHS Solution
TECH EHS Solution
 
Human Resources Information System (HRIS)
Amity University, Patna
 
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
Executive Business Intelligence Dashboards
vandeslie24
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
Ad

Test Driven Development using QUnit

  • 1. Test Driven Development (TDD) using QUnit By Satej Kumar Sahu Mindfire Solutions
  • 2. Contents • What is TDD? • A look into BDD • Real life example • TDD concepts • What is QUnit? • QUnit API sample use cases with examples • TDD using unit tests with QUnit • Conclusion
  • 3. Simple Testing • What is Testing? • Who does it? Is it solely confined as a role of QA? • Sometimes gives you a feeling of being Sherlock Holmes (The famous detective you know) in a mystery. • Some examples of simple testing may include: - Manual browser testing - Echo, exit testing - Debug tools like xDebug, IDE integrated debugging, breakpoints etc. • Pros: - Simple, easy to debug methods and tools. - Sometimes and in some ways are quick in showing results. • Cons: - Does not cover every aspect. - Time taking and risk prone. - Monotonous and repetitive. - In long term, not productive.
  • 4. What is TDD? • Test Driven Development • It’s a practice that embodies a test first methodology. • In either real world or the virtual world, in software industry or any other industry, TDD can / is being followed. Building a house or a room. Seminar planning. • You have requirements or cases or stories for a project. With TDD, you first start from writing test cases for requirements and then followup with development code to pass those test cases.
  • 7. A look into BDD • In contrast to TDD, BDD is when we write behaviour & specification that then drives our software development. • Behaviour & specification might seem awfully similar to tests but the difference is very subtle and important. • The main difference is just the wording. BDD uses a more verbose style so that it can be read almost like a sentence. • The ability to read your tests like a sentence is a cognitive shift in how you will think about your tests. The argument is that if you can read your tests fluidly, you will naturally write better and more comprehensive tests. • BDD tests should be more focused on the features, not the actual results. • https://github.com/joshuaclayton/specit
  • 8. Real life example • As the saying goes for a tailor “Measure twice, cut once” • A Tailor -> Software Developer • Notes the cloth requirement -> Project requirement • Starts with measurement, prototypes using sketches, software models -> Test cases • Starts cutting cloth with every minute precision of measurement being compared with tools against specifications -> Code development and running test cases reiteration.
  • 9. TDD concepts • Steps of TDD: - Test first - “Make it run” - Refactor / Make it better. • Refactoring: Act of restructuring, rewriting, renaming and removing code in order to improve: - Design - Readability - Maintainability • 3 A’s of Unit Testing: - Assemble - Act - Assert • Unit Test: Focus is on individual components. • From unit tests, one can proceed on to end to end testing where focus is on complete behaviour of a feature.
  • 10. • A simple test case written using console.log • Need of unit test frameworks for testing • Provide tools and APIs to test. • A framework that provides a test runner, as well as some utilities to write the actual tests.
  • 11. What is QUnit? • QUnit is a powerful, easy-to-use JavaScript unit testing framework. • It's used by the jQuery, jQuery UI and jQuery Mobile projects and is capable of testing any generic JavaScript code, including itself! • http://qunitjs.com/
  • 12. QUnit user interface and it's various parts.
  • 13. QUnit API sample use cases with examples • ok( truthy [, message ] ) • equal( actual, expected [, message ] ) • strictEqual() • deepEqual( actual, expected [, message ] ) • expect() -> testing callbacks • async() • QUnit.module()
  • 14. TDD using unit tests with QUnit
  • 15. • Advantages: - Your application is test covered. - Customers, clients and developers are more confident about their application robustness. - Tests are automated. You just need to run it. Can be part of a CI process. - Productivity increases. - You implement features and fixes without worrying about what you have broken. - Testing can also drive the design of software. Unit block codes are present and are decoupled and independent. TDD thinking helps in better API design. - It acts as a documentation for your application.
  • 16. Some practical use cases of QUnit • https://github.com/jquery/jquery/tree/master/test/unit • https://github.com/jquery/jquery-ui/tree/master/tests/unit • https://github.com/jzaefferer/jquery-validation/tree/master/te
  • 17. References • http://hubpages.com/business/Test-First-A-Real-Life-Ex • http://qunitjs.com/ • http://qunitjs.com/cookbook/ • http://qunitjs.com/plugins/
  • 19. Any?