SlideShare a Scribd company logo
Introduction to BDD
Late Debugging
• ???
Unit testing and Module testing
• In unit testing, developers create small tests
during development to check correct behavior
of software

• In module testing, dedicated testers test
software thoroughly after development
What is TDD?
• Test Driven Development
• In TDD, we write unit test before writing
actual code, and then we write the code so
that they pass the test
• This process is known as Red-Green-Refactor
process
Red-Green-Refactor

Write/run test
and see it fail

Add code to
make it pass

Refactor code
for further
improvement
What is BDD?
• Behavior Driven Development
• BDD focuses on the behaviors of software that
are most important to the customers. In BDD,
customers are actively involved in the
development process by means of User stories
BDD User Stories
• BDD user stories are usually written in this
format
Story: [Title]
As [Role]
I want [Feature]
To [Benefit]

Story: [I buy juice]
As [a thirsty person]
I want [to buy juice]
To [drink it and stay hydrated]

Scenario1: [Title]
Given [Context]
AND [Other Context]
When [Event]
Then [Outcome]
AND [Other Outcome]

Scenario1: [Enough money & near vending machine]
Given [I have enough money]
AND [I have access to vending machine]
When [I put money and select juice]
Then [I should get the juice]
AND [I should be able to drink it]
What is Mocha.JS?
• Mocha.js is a testing framework for javascript
that runs on both browser and Node.js server
• Using Mocha, we usually write test code for
each functions of our source code. We can tell
mocha to report error when the output of a
test is a certain value
Mocha.JS client example
(test.html)
<html>
<head>
<title>Mocha Tests</title>
<link rel="stylesheet" href="mocha.css" /> <!– load the mocha css file -->
</head>
<body>
<div id="mocha"></div>
<script src="jquery.js"></script>
<script>function assert(expr, msg) {if (!expr) throw new Error(msg || 'failed');}
</script> <!– assertion method -->
<script src="mocha.js"></script> <!– load the mocha.js library -->
<script>mocha.setup('bdd')</script> <!– setup mocha.js to use BDD style -->
<script src="test.array.js"></script> <!– an example test that tests array -->
<script src="test.object.js"></script> <!– an example test that tests objects -->
<script src="test.xhr.js"></script> <!– an example test that tests xhr -->
<script>
mocha.checkLeaks();
mocha.globals(['jQuery']);
mocha.run(); <!– start the test -->
</script>
</body>
</html>
How to write a Mocha.js test
(test.array.js)
describe('Array', function(){ //test suite for array object
describe('#pop()', function(){ //test suite for pop method
it('should remove and return the last value', function(){ //a test case
var arr = [1,2,3];
assert(arr.pop() == 3); //pop method removes the last element and returns it
assert(arr.pop() == 2);
assert(arr.pop() == -1); //this will generate error since it should be 1 not -1
})

it('should adjust .length', function(){ //another test case
var arr = [1,2,3];
arr.pop();
assert(arr.length == 2);
})
})
})
Mocha.js and assertion libraries
• The assert function in the previous works like
this:
function assert(expr, msg) {
//if expr is false, throw error
if (!expr) throw new Error(msg || 'failed');
}

• But we can also use assertion libraries like
should.js, expect.js, chai.js etc
The test (test.array.js) rewritten
using chai.js
describe('Array', function(){ //test suite for array object
describe('#pop()', function(){ //test suite for pop method
it('should remove and return the last value', function(){ //a test case
var arr = [1,2,3];
arr.pop().should.equal(3);
arr.pop().should.equal(2);
arr.pop().should.equal(-1); //generate error
})

it('should adjust .length', function(){ //another test case
var arr = [1,2,3];
arr.pop();
arr.length.should.equal(2)
})
})
})
UI Testing
• When we develop a software with graphical
user interface, it also becomes necessary to
test that the interface behaves correctly in
addition to testing the behaviors of functions
• However, since it becomes a tedious task to
manually operate and test intereface manually
everytime you change code, automated
testing frameworks are created

More Related Content

What's hot

Testing Ext JS and Sencha Touch
Testing Ext JS and Sencha TouchTesting Ext JS and Sencha Touch
Testing Ext JS and Sencha Touch
Mats Bryntse
 
Requirejs
RequirejsRequirejs
Requirejs
sioked
 
BDD in Drupal 8 Using Behat, mink and Selenium
BDD in Drupal 8 Using Behat, mink and SeleniumBDD in Drupal 8 Using Behat, mink and Selenium
BDD in Drupal 8 Using Behat, mink and Selenium
Eugene Vozniuk
 
Managing JavaScript Dependencies With RequireJS
Managing JavaScript Dependencies With RequireJSManaging JavaScript Dependencies With RequireJS
Managing JavaScript Dependencies With RequireJS
Den Odell
 
Odoo Experience 2018 - Odoo Studio as a Prototyping Tool
Odoo Experience 2018 - Odoo Studio as a Prototyping ToolOdoo Experience 2018 - Odoo Studio as a Prototyping Tool
Odoo Experience 2018 - Odoo Studio as a Prototyping Tool
ElínAnna Jónasdóttir
 
Сергей Больщиков "Protractor Tips & Tricks"
Сергей Больщиков "Protractor Tips & Tricks"Сергей Больщиков "Protractor Tips & Tricks"
Сергей Больщиков "Protractor Tips & Tricks"
Fwdays
 
2015 in tothebox-introtddbdd
2015 in tothebox-introtddbdd2015 in tothebox-introtddbdd
2015 in tothebox-introtddbdd
ColdFusionConference
 
Nagios Conference 2014 - Troy Lea - JavaScript and jQuery - Nagios XI Tips, T...
Nagios Conference 2014 - Troy Lea - JavaScript and jQuery - Nagios XI Tips, T...Nagios Conference 2014 - Troy Lea - JavaScript and jQuery - Nagios XI Tips, T...
Nagios Conference 2014 - Troy Lea - JavaScript and jQuery - Nagios XI Tips, T...
Nagios
 

What's hot (8)

Testing Ext JS and Sencha Touch
Testing Ext JS and Sencha TouchTesting Ext JS and Sencha Touch
Testing Ext JS and Sencha Touch
 
Requirejs
RequirejsRequirejs
Requirejs
 
BDD in Drupal 8 Using Behat, mink and Selenium
BDD in Drupal 8 Using Behat, mink and SeleniumBDD in Drupal 8 Using Behat, mink and Selenium
BDD in Drupal 8 Using Behat, mink and Selenium
 
Managing JavaScript Dependencies With RequireJS
Managing JavaScript Dependencies With RequireJSManaging JavaScript Dependencies With RequireJS
Managing JavaScript Dependencies With RequireJS
 
Odoo Experience 2018 - Odoo Studio as a Prototyping Tool
Odoo Experience 2018 - Odoo Studio as a Prototyping ToolOdoo Experience 2018 - Odoo Studio as a Prototyping Tool
Odoo Experience 2018 - Odoo Studio as a Prototyping Tool
 
Сергей Больщиков "Protractor Tips & Tricks"
Сергей Больщиков "Protractor Tips & Tricks"Сергей Больщиков "Protractor Tips & Tricks"
Сергей Больщиков "Protractor Tips & Tricks"
 
2015 in tothebox-introtddbdd
2015 in tothebox-introtddbdd2015 in tothebox-introtddbdd
2015 in tothebox-introtddbdd
 
Nagios Conference 2014 - Troy Lea - JavaScript and jQuery - Nagios XI Tips, T...
Nagios Conference 2014 - Troy Lea - JavaScript and jQuery - Nagios XI Tips, T...Nagios Conference 2014 - Troy Lea - JavaScript and jQuery - Nagios XI Tips, T...
Nagios Conference 2014 - Troy Lea - JavaScript and jQuery - Nagios XI Tips, T...
 

Viewers also liked

Unit Testing Best Practices
Unit Testing Best PracticesUnit Testing Best Practices
Unit Testing Best PracticesTomaš Maconko
 
Productivity tips for tech professionals
Productivity tips for tech professionalsProductivity tips for tech professionals
Productivity tips for tech professionals
Atish Narlawar
 
Behaviour driven development aka bdd
Behaviour driven development aka bddBehaviour driven development aka bdd
Behaviour driven development aka bdd
Prince Gupta
 
Unit testing best practices with JUnit
Unit testing best practices with JUnitUnit testing best practices with JUnit
Unit testing best practices with JUnit
inTwentyEight Minutes
 
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
Rhoynar Software Consulting
 
Agile масштабирование компании
Agile масштабирование компанииAgile масштабирование компании
Agile масштабирование компании
Timofey (Tim) Yevgrashyn
 
BDD - beyond: Given, When and Then
BDD - beyond: Given, When and ThenBDD - beyond: Given, When and Then
BDD - beyond: Given, When and Then
RiverGlide
 
Масштабирование Agile: Challenge Accepted
Масштабирование Agile: Challenge Accepted Масштабирование Agile: Challenge Accepted
Масштабирование Agile: Challenge Accepted
Antonina Binetskaya
 
Mocha.js
Mocha.jsMocha.js
Mocha.js
LearningTech
 
Frontend Operations
Frontend OperationsFrontend Operations
Frontend Operations
Philippe Antoine
 
Масштабирование Agile/Lean разработки в рамках программы (Александр Якима)
Масштабирование Agile/Lean разработки в рамках программы (Александр Якима)Масштабирование Agile/Lean разработки в рамках программы (Александр Якима)
Масштабирование Agile/Lean разработки в рамках программы (Александр Якима)Ontico
 
Web based automation testing on Node.js environment
Web based automation testing on Node.js environmentWeb based automation testing on Node.js environment
Web based automation testing on Node.js environment
Yu-Lin Huang
 
Scrum Bangalore 13th meet up 13 june 2015 - behaviour driven development - vi...
Scrum Bangalore 13th meet up 13 june 2015 - behaviour driven development - vi...Scrum Bangalore 13th meet up 13 june 2015 - behaviour driven development - vi...
Scrum Bangalore 13th meet up 13 june 2015 - behaviour driven development - vi...
Scrum Bangalore
 
Making the Move to Behavior Driven Development
Making the Move to Behavior Driven DevelopmentMaking the Move to Behavior Driven Development
Making the Move to Behavior Driven Development
QASymphony
 
The Road To Redux
The Road To ReduxThe Road To Redux
The Road To Redux
Jeffrey Sanchez
 
Test Automation With Cucumber JVM, Selenium, and Mocha
Test Automation With Cucumber JVM, Selenium, and MochaTest Automation With Cucumber JVM, Selenium, and Mocha
Test Automation With Cucumber JVM, Selenium, and Mocha
Salesforce Developers
 
Postman Collection Format v2.0 (pre-draft)
Postman Collection Format v2.0 (pre-draft)Postman Collection Format v2.0 (pre-draft)
Postman Collection Format v2.0 (pre-draft)
Postman
 
Introduction to Bdd and cucumber
Introduction to Bdd and cucumberIntroduction to Bdd and cucumber
Introduction to Bdd and cucumber
Nibu Baby
 
Using CI for continuous delivery Part 1
Using CI for continuous delivery Part 1Using CI for continuous delivery Part 1
Using CI for continuous delivery Part 1
Vishal Biyani
 

Viewers also liked (20)

Born Digital - Dan Franklin
Born Digital - Dan FranklinBorn Digital - Dan Franklin
Born Digital - Dan Franklin
 
Unit Testing Best Practices
Unit Testing Best PracticesUnit Testing Best Practices
Unit Testing Best Practices
 
Productivity tips for tech professionals
Productivity tips for tech professionalsProductivity tips for tech professionals
Productivity tips for tech professionals
 
Behaviour driven development aka bdd
Behaviour driven development aka bddBehaviour driven development aka bdd
Behaviour driven development aka bdd
 
Unit testing best practices with JUnit
Unit testing best practices with JUnitUnit testing best practices with JUnit
Unit testing best practices with JUnit
 
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
 
Agile масштабирование компании
Agile масштабирование компанииAgile масштабирование компании
Agile масштабирование компании
 
BDD - beyond: Given, When and Then
BDD - beyond: Given, When and ThenBDD - beyond: Given, When and Then
BDD - beyond: Given, When and Then
 
Масштабирование Agile: Challenge Accepted
Масштабирование Agile: Challenge Accepted Масштабирование Agile: Challenge Accepted
Масштабирование Agile: Challenge Accepted
 
Mocha.js
Mocha.jsMocha.js
Mocha.js
 
Frontend Operations
Frontend OperationsFrontend Operations
Frontend Operations
 
Масштабирование Agile/Lean разработки в рамках программы (Александр Якима)
Масштабирование Agile/Lean разработки в рамках программы (Александр Якима)Масштабирование Agile/Lean разработки в рамках программы (Александр Якима)
Масштабирование Agile/Lean разработки в рамках программы (Александр Якима)
 
Web based automation testing on Node.js environment
Web based automation testing on Node.js environmentWeb based automation testing on Node.js environment
Web based automation testing on Node.js environment
 
Scrum Bangalore 13th meet up 13 june 2015 - behaviour driven development - vi...
Scrum Bangalore 13th meet up 13 june 2015 - behaviour driven development - vi...Scrum Bangalore 13th meet up 13 june 2015 - behaviour driven development - vi...
Scrum Bangalore 13th meet up 13 june 2015 - behaviour driven development - vi...
 
Making the Move to Behavior Driven Development
Making the Move to Behavior Driven DevelopmentMaking the Move to Behavior Driven Development
Making the Move to Behavior Driven Development
 
The Road To Redux
The Road To ReduxThe Road To Redux
The Road To Redux
 
Test Automation With Cucumber JVM, Selenium, and Mocha
Test Automation With Cucumber JVM, Selenium, and MochaTest Automation With Cucumber JVM, Selenium, and Mocha
Test Automation With Cucumber JVM, Selenium, and Mocha
 
Postman Collection Format v2.0 (pre-draft)
Postman Collection Format v2.0 (pre-draft)Postman Collection Format v2.0 (pre-draft)
Postman Collection Format v2.0 (pre-draft)
 
Introduction to Bdd and cucumber
Introduction to Bdd and cucumberIntroduction to Bdd and cucumber
Introduction to Bdd and cucumber
 
Using CI for continuous delivery Part 1
Using CI for continuous delivery Part 1Using CI for continuous delivery Part 1
Using CI for continuous delivery Part 1
 

Similar to Introduction to bdd

Intro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiIntro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiRan Mizrahi
 
Perl Behavior Driven Development (BDD)
Perl Behavior Driven Development (BDD)Perl Behavior Driven Development (BDD)
Perl Behavior Driven Development (BDD)
Tudor Constantin
 
Cucumber - use it to describe user stories and acceptance criterias
Cucumber - use it to describe user stories and acceptance criteriasCucumber - use it to describe user stories and acceptance criterias
Cucumber - use it to describe user stories and acceptance criterias
Geison Goes
 
Database continuous integration, unit test and functional test
Database continuous integration, unit test and functional testDatabase continuous integration, unit test and functional test
Database continuous integration, unit test and functional test
Harry Zheng
 
2014 11 20 Drupal 7 -> 8 test migratie
2014 11 20 Drupal 7 -> 8 test migratie2014 11 20 Drupal 7 -> 8 test migratie
2014 11 20 Drupal 7 -> 8 test migratie
hcderaad
 
Testing - How Vital and How Easy to use
Testing - How Vital and How Easy to useTesting - How Vital and How Easy to use
Testing - How Vital and How Easy to use
Uma Ghotikar
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Ortus Solutions, Corp
 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by Example
Nalin Goonawardana
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Uma Ghotikar
 
German Testing Day 2015 - How behavior-driven development fuses developers an...
German Testing Day 2015 - How behavior-driven development fuses developers an...German Testing Day 2015 - How behavior-driven development fuses developers an...
German Testing Day 2015 - How behavior-driven development fuses developers an...
Bastian Seehaus
 
BDD Selenium for Agile Teams - User Stories
BDD Selenium for Agile Teams - User StoriesBDD Selenium for Agile Teams - User Stories
BDD Selenium for Agile Teams - User Stories
Sauce Labs
 
3 WAYS TO TEST YOUR COLDFUSION API
3 WAYS TO TEST YOUR COLDFUSION API3 WAYS TO TEST YOUR COLDFUSION API
3 WAYS TO TEST YOUR COLDFUSION API
Gavin Pickin
 
3 WAYS TO TEST YOUR COLDFUSION API -
3 WAYS TO TEST YOUR COLDFUSION API - 3 WAYS TO TEST YOUR COLDFUSION API -
3 WAYS TO TEST YOUR COLDFUSION API -
Ortus Solutions, Corp
 
Useful practices of creation automatic tests by using cucumber jvm
Useful practices of creation automatic tests by using cucumber jvmUseful practices of creation automatic tests by using cucumber jvm
Useful practices of creation automatic tests by using cucumber jvm
Anton Shapin
 
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
Speedment, Inc.
 
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
Malin Weiss
 
Continuous Quality
Continuous QualityContinuous Quality
Continuous Quality
Stefano Galati
 
How to generate customized java 8 code from your database
How to generate customized java 8 code from your databaseHow to generate customized java 8 code from your database
How to generate customized java 8 code from your database
Speedment, Inc.
 

Similar to Introduction to bdd (20)

Intro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiIntro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran Mizrahi
 
Perl Behavior Driven Development (BDD)
Perl Behavior Driven Development (BDD)Perl Behavior Driven Development (BDD)
Perl Behavior Driven Development (BDD)
 
Cucumber - use it to describe user stories and acceptance criterias
Cucumber - use it to describe user stories and acceptance criteriasCucumber - use it to describe user stories and acceptance criterias
Cucumber - use it to describe user stories and acceptance criterias
 
Database continuous integration, unit test and functional test
Database continuous integration, unit test and functional testDatabase continuous integration, unit test and functional test
Database continuous integration, unit test and functional test
 
2014 11 20 Drupal 7 -> 8 test migratie
2014 11 20 Drupal 7 -> 8 test migratie2014 11 20 Drupal 7 -> 8 test migratie
2014 11 20 Drupal 7 -> 8 test migratie
 
Testing - How Vital and How Easy to use
Testing - How Vital and How Easy to useTesting - How Vital and How Easy to use
Testing - How Vital and How Easy to use
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by Example
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
 
German Testing Day 2015 - How behavior-driven development fuses developers an...
German Testing Day 2015 - How behavior-driven development fuses developers an...German Testing Day 2015 - How behavior-driven development fuses developers an...
German Testing Day 2015 - How behavior-driven development fuses developers an...
 
Cucumber_Training_ForQA
Cucumber_Training_ForQACucumber_Training_ForQA
Cucumber_Training_ForQA
 
BDD Selenium for Agile Teams - User Stories
BDD Selenium for Agile Teams - User StoriesBDD Selenium for Agile Teams - User Stories
BDD Selenium for Agile Teams - User Stories
 
3 WAYS TO TEST YOUR COLDFUSION API
3 WAYS TO TEST YOUR COLDFUSION API3 WAYS TO TEST YOUR COLDFUSION API
3 WAYS TO TEST YOUR COLDFUSION API
 
3 WAYS TO TEST YOUR COLDFUSION API -
3 WAYS TO TEST YOUR COLDFUSION API - 3 WAYS TO TEST YOUR COLDFUSION API -
3 WAYS TO TEST YOUR COLDFUSION API -
 
Zend
ZendZend
Zend
 
Useful practices of creation automatic tests by using cucumber jvm
Useful practices of creation automatic tests by using cucumber jvmUseful practices of creation automatic tests by using cucumber jvm
Useful practices of creation automatic tests by using cucumber jvm
 
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
 
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
 
Continuous Quality
Continuous QualityContinuous Quality
Continuous Quality
 
How to generate customized java 8 code from your database
How to generate customized java 8 code from your databaseHow to generate customized java 8 code from your database
How to generate customized java 8 code from your database
 

Recently uploaded

Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
gb193092
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 

Recently uploaded (20)

Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 

Introduction to bdd

  • 3. Unit testing and Module testing • In unit testing, developers create small tests during development to check correct behavior of software • In module testing, dedicated testers test software thoroughly after development
  • 4. What is TDD? • Test Driven Development • In TDD, we write unit test before writing actual code, and then we write the code so that they pass the test • This process is known as Red-Green-Refactor process
  • 5. Red-Green-Refactor Write/run test and see it fail Add code to make it pass Refactor code for further improvement
  • 6. What is BDD? • Behavior Driven Development • BDD focuses on the behaviors of software that are most important to the customers. In BDD, customers are actively involved in the development process by means of User stories
  • 7. BDD User Stories • BDD user stories are usually written in this format Story: [Title] As [Role] I want [Feature] To [Benefit] Story: [I buy juice] As [a thirsty person] I want [to buy juice] To [drink it and stay hydrated] Scenario1: [Title] Given [Context] AND [Other Context] When [Event] Then [Outcome] AND [Other Outcome] Scenario1: [Enough money & near vending machine] Given [I have enough money] AND [I have access to vending machine] When [I put money and select juice] Then [I should get the juice] AND [I should be able to drink it]
  • 8. What is Mocha.JS? • Mocha.js is a testing framework for javascript that runs on both browser and Node.js server • Using Mocha, we usually write test code for each functions of our source code. We can tell mocha to report error when the output of a test is a certain value
  • 9. Mocha.JS client example (test.html) <html> <head> <title>Mocha Tests</title> <link rel="stylesheet" href="mocha.css" /> <!– load the mocha css file --> </head> <body> <div id="mocha"></div> <script src="jquery.js"></script> <script>function assert(expr, msg) {if (!expr) throw new Error(msg || 'failed');} </script> <!– assertion method --> <script src="mocha.js"></script> <!– load the mocha.js library --> <script>mocha.setup('bdd')</script> <!– setup mocha.js to use BDD style --> <script src="test.array.js"></script> <!– an example test that tests array --> <script src="test.object.js"></script> <!– an example test that tests objects --> <script src="test.xhr.js"></script> <!– an example test that tests xhr --> <script> mocha.checkLeaks(); mocha.globals(['jQuery']); mocha.run(); <!– start the test --> </script> </body> </html>
  • 10. How to write a Mocha.js test (test.array.js) describe('Array', function(){ //test suite for array object describe('#pop()', function(){ //test suite for pop method it('should remove and return the last value', function(){ //a test case var arr = [1,2,3]; assert(arr.pop() == 3); //pop method removes the last element and returns it assert(arr.pop() == 2); assert(arr.pop() == -1); //this will generate error since it should be 1 not -1 }) it('should adjust .length', function(){ //another test case var arr = [1,2,3]; arr.pop(); assert(arr.length == 2); }) }) })
  • 11. Mocha.js and assertion libraries • The assert function in the previous works like this: function assert(expr, msg) { //if expr is false, throw error if (!expr) throw new Error(msg || 'failed'); } • But we can also use assertion libraries like should.js, expect.js, chai.js etc
  • 12. The test (test.array.js) rewritten using chai.js describe('Array', function(){ //test suite for array object describe('#pop()', function(){ //test suite for pop method it('should remove and return the last value', function(){ //a test case var arr = [1,2,3]; arr.pop().should.equal(3); arr.pop().should.equal(2); arr.pop().should.equal(-1); //generate error }) it('should adjust .length', function(){ //another test case var arr = [1,2,3]; arr.pop(); arr.length.should.equal(2) }) }) })
  • 13. UI Testing • When we develop a software with graphical user interface, it also becomes necessary to test that the interface behaves correctly in addition to testing the behaviors of functions • However, since it becomes a tedious task to manually operate and test intereface manually everytime you change code, automated testing frameworks are created