SlideShare uma empresa Scribd logo
1 de 8
QUnit
         A
     JavaScript
Testing Framework
Outline
What Is QUnit?





Creating Tests with QUnit





References

What Is QUnit?


    QUnit is the testing suite for jQuery scripts and
    plugins.


    It doesn't need jQuery scripts to test other javascript
    codes.
Creating Tests with QUnit


    Download the QUnit script (and the optional QUnit
    css)


    Create test script to run against target external
    javascript


    Create html file to display test results
Sample Function to Test

function addNumbers(num1, num2) {
  if (isNaN(num1)) {
      return "First parameter is NaN";
  } else if (isNaN(num2)) {
      return "Second parameter is NaN";
  } else {
      return num1 + num2;
  }
}
Unit Test Script


test('addNumbers()', function() {
   equal(addNumbers(1,2), 3, 'using equal()');
})
The HTML File
<html>
<head>
    <title>QUnit Test Suite</title>
   <link rel="stylesheet" type="text/css" media="all"
href="qunit.css" />
    <script type="text/javascript" src="qunit.js"></script>
    <!-- Your project file goes here -->
    <script type="text/javascript" src="sourceScript.js"></script>

    <!-- Your tests file goes here -->
    <script type="text/javascript"
src="sourceScriptTest.js"></script>
</head>
<body>
    <h1 id="qunit-header">QUnit Test Suite for
sourceScript.js</h1>
    <h2 id="qunit-banner"></h2>
    <div id="qunit-testrunner-toolbar"></div>
    <h2 id="qunit-userAgent"></h2>
    <ol id="qunit-tests"></ol>
</body>
</html>
References

 net.tutsplus.com/tutorials/javascript-ajax/
how-to-test-your-javascript-code-with-qunit/

          docs.jquery.com/QUnit

Mais conteúdo relacionado

Destaque

Derecho Privado
Derecho PrivadoDerecho Privado
Derecho Privadodiego1998
 
Marketing Day - French Style or German Reliability - Alex Kowalczyk
Marketing Day - French Style or German Reliability - Alex KowalczykMarketing Day - French Style or German Reliability - Alex Kowalczyk
Marketing Day - French Style or German Reliability - Alex KowalczykAlek Kowalczyk
 
Las_comunidades_de_práctica
Las_comunidades_de_prácticaLas_comunidades_de_práctica
Las_comunidades_de_prácticagarmonte
 
Hoja de ruta jornada de inducción a madres y padres
Hoja de ruta jornada de inducción a madres y padresHoja de ruta jornada de inducción a madres y padres
Hoja de ruta jornada de inducción a madres y padresHilda Aimituma
 
интересные факты из истории олимпийских игр1
интересные факты из истории олимпийских игр1интересные факты из истории олимпийских игр1
интересные факты из истории олимпийских игр1Елена Денисова
 
How Pokemon GO Can Drive Your Sales
How Pokemon GO Can Drive Your SalesHow Pokemon GO Can Drive Your Sales
How Pokemon GO Can Drive Your SalesGoECart
 
嘔氣~不要跟你所在乎的人
嘔氣~不要跟你所在乎的人嘔氣~不要跟你所在乎的人
嘔氣~不要跟你所在乎的人meihung06
 
Mannaclean| Protecting Assets, Improving Quality of Life
Mannaclean| Protecting Assets, Improving Quality of LifeMannaclean| Protecting Assets, Improving Quality of Life
Mannaclean| Protecting Assets, Improving Quality of LifeTara Lynn Gray
 
Cuerpo espacio y tiempo en propuesta docente
Cuerpo espacio y tiempo en propuesta docenteCuerpo espacio y tiempo en propuesta docente
Cuerpo espacio y tiempo en propuesta docentegarmonte
 
How To Make Your Day Last Longer: Time Management in Marketing Projects
How To Make Your Day Last Longer: Time Management in Marketing Projects How To Make Your Day Last Longer: Time Management in Marketing Projects
How To Make Your Day Last Longer: Time Management in Marketing Projects Alek Kowalczyk
 
Prepositions workshop
Prepositions workshopPrepositions workshop
Prepositions workshopdarkcrow08
 
Google App Engine - unusual application plaform for your next SaaS Project
Google App Engine - unusual application plaform for your next SaaS ProjectGoogle App Engine - unusual application plaform for your next SaaS Project
Google App Engine - unusual application plaform for your next SaaS ProjectAlek Kowalczyk
 
Levin library databases page redesign
Levin library databases page redesignLevin library databases page redesign
Levin library databases page redesignEmily Singley
 
Phm 1.1.5(Harman S. Gahir)
Phm 1.1.5(Harman S. Gahir)Phm 1.1.5(Harman S. Gahir)
Phm 1.1.5(Harman S. Gahir)Harman Gahir
 

Destaque (18)

Derecho Privado
Derecho PrivadoDerecho Privado
Derecho Privado
 
Marketing Day - French Style or German Reliability - Alex Kowalczyk
Marketing Day - French Style or German Reliability - Alex KowalczykMarketing Day - French Style or German Reliability - Alex Kowalczyk
Marketing Day - French Style or German Reliability - Alex Kowalczyk
 
Raven
RavenRaven
Raven
 
Las_comunidades_de_práctica
Las_comunidades_de_prácticaLas_comunidades_de_práctica
Las_comunidades_de_práctica
 
Hoja de ruta jornada de inducción a madres y padres
Hoja de ruta jornada de inducción a madres y padresHoja de ruta jornada de inducción a madres y padres
Hoja de ruta jornada de inducción a madres y padres
 
интересные факты из истории олимпийских игр1
интересные факты из истории олимпийских игр1интересные факты из истории олимпийских игр1
интересные факты из истории олимпийских игр1
 
2011 (3) feb 1 15
2011 (3) feb 1 152011 (3) feb 1 15
2011 (3) feb 1 15
 
How Pokemon GO Can Drive Your Sales
How Pokemon GO Can Drive Your SalesHow Pokemon GO Can Drive Your Sales
How Pokemon GO Can Drive Your Sales
 
嘔氣~不要跟你所在乎的人
嘔氣~不要跟你所在乎的人嘔氣~不要跟你所在乎的人
嘔氣~不要跟你所在乎的人
 
Mannaclean| Protecting Assets, Improving Quality of Life
Mannaclean| Protecting Assets, Improving Quality of LifeMannaclean| Protecting Assets, Improving Quality of Life
Mannaclean| Protecting Assets, Improving Quality of Life
 
Cuerpo espacio y tiempo en propuesta docente
Cuerpo espacio y tiempo en propuesta docenteCuerpo espacio y tiempo en propuesta docente
Cuerpo espacio y tiempo en propuesta docente
 
How To Make Your Day Last Longer: Time Management in Marketing Projects
How To Make Your Day Last Longer: Time Management in Marketing Projects How To Make Your Day Last Longer: Time Management in Marketing Projects
How To Make Your Day Last Longer: Time Management in Marketing Projects
 
Prepositions workshop
Prepositions workshopPrepositions workshop
Prepositions workshop
 
Google App Engine - unusual application plaform for your next SaaS Project
Google App Engine - unusual application plaform for your next SaaS ProjectGoogle App Engine - unusual application plaform for your next SaaS Project
Google App Engine - unusual application plaform for your next SaaS Project
 
Levin library databases page redesign
Levin library databases page redesignLevin library databases page redesign
Levin library databases page redesign
 
Generosity during economic downturn
Generosity during economic downturnGenerosity during economic downturn
Generosity during economic downturn
 
La cigarra y la hormiga
La cigarra y la hormigaLa cigarra y la hormiga
La cigarra y la hormiga
 
Phm 1.1.5(Harman S. Gahir)
Phm 1.1.5(Harman S. Gahir)Phm 1.1.5(Harman S. Gahir)
Phm 1.1.5(Harman S. Gahir)
 

Mais de Exist

Postgres Powers Digital Transformation in Southeast Asia – Success Stories
Postgres Powers Digital Transformation in Southeast Asia – Success StoriesPostgres Powers Digital Transformation in Southeast Asia – Success Stories
Postgres Powers Digital Transformation in Southeast Asia – Success StoriesExist
 
Understanding Blockchain and Its Business Benefits
Understanding Blockchain and Its Business BenefitsUnderstanding Blockchain and Its Business Benefits
Understanding Blockchain and Its Business BenefitsExist
 
ブロックチェーンのビジネス上の利点を理解する
ブロックチェーンのビジネス上の利点を理解するブロックチェーンのビジネス上の利点を理解する
ブロックチェーンのビジネス上の利点を理解するExist
 
How to Select the Right Automation Testing Tool
How to Select the Right Automation Testing ToolHow to Select the Right Automation Testing Tool
How to Select the Right Automation Testing ToolExist
 
Advancing Global Competitiveness Through Digital Transformation and Big Data ...
Advancing Global Competitiveness Through Digital Transformation and Big Data ...Advancing Global Competitiveness Through Digital Transformation and Big Data ...
Advancing Global Competitiveness Through Digital Transformation and Big Data ...Exist
 
Exist Company Profile
Exist Company ProfileExist Company Profile
Exist Company ProfileExist
 
Exist Company Profile (Nihongo)
Exist Company Profile (Nihongo)Exist Company Profile (Nihongo)
Exist Company Profile (Nihongo)Exist
 
DX(デジタルトランスフォーメーション)とビッグデータでグローバル競争力強化を図ります
DX(デジタルトランスフォーメーション)とビッグデータでグローバル競争力強化を図りますDX(デジタルトランスフォーメーション)とビッグデータでグローバル競争力強化を図ります
DX(デジタルトランスフォーメーション)とビッグデータでグローバル競争力強化を図りますExist
 
Anahaw Retail Enterprise Solution
Anahaw Retail Enterprise SolutionAnahaw Retail Enterprise Solution
Anahaw Retail Enterprise SolutionExist
 
Understanding the state of your web application using Apache Kafka, Spark
Understanding the state of your web application using Apache Kafka, SparkUnderstanding the state of your web application using Apache Kafka, Spark
Understanding the state of your web application using Apache Kafka, SparkExist
 
The Philippines eHealth Strategic Framework and Plan (Updates as of May 23, 2...
The Philippines eHealth Strategic Framework and Plan (Updates as of May 23, 2...The Philippines eHealth Strategic Framework and Plan (Updates as of May 23, 2...
The Philippines eHealth Strategic Framework and Plan (Updates as of May 23, 2...Exist
 
API-Centric Rails Web Apps and Hybrid Mobile App Integration
API-Centric Rails Web Apps and Hybrid Mobile App IntegrationAPI-Centric Rails Web Apps and Hybrid Mobile App Integration
API-Centric Rails Web Apps and Hybrid Mobile App IntegrationExist
 
Clinical Analytics for Improving Health Outcomes
Clinical Analytics for Improving Health OutcomesClinical Analytics for Improving Health Outcomes
Clinical Analytics for Improving Health OutcomesExist
 
Exist Customer Success Stories
Exist Customer Success StoriesExist Customer Success Stories
Exist Customer Success StoriesExist
 
Node.js Presentation
Node.js PresentationNode.js Presentation
Node.js PresentationExist
 
Selenium RC Using Java and Maven + Maestro Integration
Selenium RC Using Java and Maven + Maestro IntegrationSelenium RC Using Java and Maven + Maestro Integration
Selenium RC Using Java and Maven + Maestro IntegrationExist
 
Philippine Digital Strategy
Philippine Digital StrategyPhilippine Digital Strategy
Philippine Digital StrategyExist
 
Spectrum of IT BPO Services in the Philippines
Spectrum of IT BPO Services in the PhilippinesSpectrum of IT BPO Services in the Philippines
Spectrum of IT BPO Services in the PhilippinesExist
 
What's new in Drupal 7
What's new in Drupal 7What's new in Drupal 7
What's new in Drupal 7Exist
 
Intro to jQuery
Intro to jQueryIntro to jQuery
Intro to jQueryExist
 

Mais de Exist (20)

Postgres Powers Digital Transformation in Southeast Asia – Success Stories
Postgres Powers Digital Transformation in Southeast Asia – Success StoriesPostgres Powers Digital Transformation in Southeast Asia – Success Stories
Postgres Powers Digital Transformation in Southeast Asia – Success Stories
 
Understanding Blockchain and Its Business Benefits
Understanding Blockchain and Its Business BenefitsUnderstanding Blockchain and Its Business Benefits
Understanding Blockchain and Its Business Benefits
 
ブロックチェーンのビジネス上の利点を理解する
ブロックチェーンのビジネス上の利点を理解するブロックチェーンのビジネス上の利点を理解する
ブロックチェーンのビジネス上の利点を理解する
 
How to Select the Right Automation Testing Tool
How to Select the Right Automation Testing ToolHow to Select the Right Automation Testing Tool
How to Select the Right Automation Testing Tool
 
Advancing Global Competitiveness Through Digital Transformation and Big Data ...
Advancing Global Competitiveness Through Digital Transformation and Big Data ...Advancing Global Competitiveness Through Digital Transformation and Big Data ...
Advancing Global Competitiveness Through Digital Transformation and Big Data ...
 
Exist Company Profile
Exist Company ProfileExist Company Profile
Exist Company Profile
 
Exist Company Profile (Nihongo)
Exist Company Profile (Nihongo)Exist Company Profile (Nihongo)
Exist Company Profile (Nihongo)
 
DX(デジタルトランスフォーメーション)とビッグデータでグローバル競争力強化を図ります
DX(デジタルトランスフォーメーション)とビッグデータでグローバル競争力強化を図りますDX(デジタルトランスフォーメーション)とビッグデータでグローバル競争力強化を図ります
DX(デジタルトランスフォーメーション)とビッグデータでグローバル競争力強化を図ります
 
Anahaw Retail Enterprise Solution
Anahaw Retail Enterprise SolutionAnahaw Retail Enterprise Solution
Anahaw Retail Enterprise Solution
 
Understanding the state of your web application using Apache Kafka, Spark
Understanding the state of your web application using Apache Kafka, SparkUnderstanding the state of your web application using Apache Kafka, Spark
Understanding the state of your web application using Apache Kafka, Spark
 
The Philippines eHealth Strategic Framework and Plan (Updates as of May 23, 2...
The Philippines eHealth Strategic Framework and Plan (Updates as of May 23, 2...The Philippines eHealth Strategic Framework and Plan (Updates as of May 23, 2...
The Philippines eHealth Strategic Framework and Plan (Updates as of May 23, 2...
 
API-Centric Rails Web Apps and Hybrid Mobile App Integration
API-Centric Rails Web Apps and Hybrid Mobile App IntegrationAPI-Centric Rails Web Apps and Hybrid Mobile App Integration
API-Centric Rails Web Apps and Hybrid Mobile App Integration
 
Clinical Analytics for Improving Health Outcomes
Clinical Analytics for Improving Health OutcomesClinical Analytics for Improving Health Outcomes
Clinical Analytics for Improving Health Outcomes
 
Exist Customer Success Stories
Exist Customer Success StoriesExist Customer Success Stories
Exist Customer Success Stories
 
Node.js Presentation
Node.js PresentationNode.js Presentation
Node.js Presentation
 
Selenium RC Using Java and Maven + Maestro Integration
Selenium RC Using Java and Maven + Maestro IntegrationSelenium RC Using Java and Maven + Maestro Integration
Selenium RC Using Java and Maven + Maestro Integration
 
Philippine Digital Strategy
Philippine Digital StrategyPhilippine Digital Strategy
Philippine Digital Strategy
 
Spectrum of IT BPO Services in the Philippines
Spectrum of IT BPO Services in the PhilippinesSpectrum of IT BPO Services in the Philippines
Spectrum of IT BPO Services in the Philippines
 
What's new in Drupal 7
What's new in Drupal 7What's new in Drupal 7
What's new in Drupal 7
 
Intro to jQuery
Intro to jQueryIntro to jQuery
Intro to jQuery
 

Último

How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 

Último (20)

How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 

JavaScript Unit Testing Using QUnit

  • 1. QUnit A JavaScript Testing Framework
  • 2. Outline What Is QUnit?  Creating Tests with QUnit  References 
  • 3. What Is QUnit?  QUnit is the testing suite for jQuery scripts and plugins.  It doesn't need jQuery scripts to test other javascript codes.
  • 4. Creating Tests with QUnit  Download the QUnit script (and the optional QUnit css)  Create test script to run against target external javascript  Create html file to display test results
  • 5. Sample Function to Test function addNumbers(num1, num2) { if (isNaN(num1)) { return "First parameter is NaN"; } else if (isNaN(num2)) { return "Second parameter is NaN"; } else { return num1 + num2; } }
  • 6. Unit Test Script test('addNumbers()', function() { equal(addNumbers(1,2), 3, 'using equal()'); })
  • 7. The HTML File <html> <head> <title>QUnit Test Suite</title> <link rel="stylesheet" type="text/css" media="all" href="qunit.css" /> <script type="text/javascript" src="qunit.js"></script> <!-- Your project file goes here --> <script type="text/javascript" src="sourceScript.js"></script> <!-- Your tests file goes here --> <script type="text/javascript" src="sourceScriptTest.js"></script> </head> <body> <h1 id="qunit-header">QUnit Test Suite for sourceScript.js</h1> <h2 id="qunit-banner"></h2> <div id="qunit-testrunner-toolbar"></div> <h2 id="qunit-userAgent"></h2> <ol id="qunit-tests"></ol> </body> </html>