SlideShare une entreprise Scribd logo
1  sur  33
BDD - Jasmine
Agenda
• Need of TDD/BDD
• Steps to BDD
• Familiarize terminology
• Installation
• Executing jasmine
• Write tests in jasmine
• What next?
TDD
• Involves writing tests before writing the code
being tested
• Write a small test first (at this point of time no
code being written!)
• Run the test (obviously, it fails!)
• Now make the test pass (well write some code)
• Observe the design, refactor
TDD - Challenges
• As the code size increases more refactor
becomes critical
• Since most of the time the features are not pre-
determined reviewing/refactoring does prove as
time consuming and becomes expensive
So what next???
• In real time objects are the carriers
• They extend the behavior of classes
• This would be mean, “what an object does is
significantly more important!”
• It’s all behavior
BDD
• Behaviour Driven Development is an Agile
development process that comprises aspects of
– Acceptance Test Driven Planning,
– Domain Driven Design
– Test Driven Development
BDD
• BDD puts the focus on Behavior rather than
structure
• Examples
– User inputting values
– Awaiting for the feedback
– Calculations/logic
• It’s all behavior
BDD Triad
• For better communication across the levels
(Business analysts, Developers, Testers) in
software development we narrate/describe the
logical chunks as scenarios
• Given/When/Then – called as BDD triad
BDD Cycle
Jasmine
Jasmine
• It’s a BDD Framework for testing JavaScript
• Does not depend on other frameworks
• Does not require a DOM
• Clean & Obvious syntax
• Influenced by Rspec, JSSpec, Jspec
• Available as stand-alone, ruby gem, Node.js module, as
Maven plugin
Principles
• Should not be tied to any browser, framework,
platform or host language
• Should have idiomatic and unsurprising syntax
• Should work wherever JavaScript runs
• Should play well with IDE’s
Goals
• It should encourage good testing practices
• It should be simple to get start with
• It should integrate easily with continuous build
systems
Terminology
•Specs
•Suites
•describe
•it
•expect
•matchers
•mocks
•spies
Installation
•Required files/structure
•Download stand alone zip file include the lib files
<script type="text/javascript" src="lib/jasmine-1.0.0.rc1/jasmine.js"></script>  
<script type="text/javascript" src="lib/jasmine-1.0.0.rc1/jasmine-html.js"></script>  
•Include styles as well
<link rel="stylesheet" type="text/css" href="lib/jasmine-1.0.0.rc1/jasmine.css">
Implementation/File structure
•jasmine-example/
• lib/
• jasmine-1.3.1/jasmine.js
• jasmine-1.3.1/jasmine-html.js
• jasmine-1.0.0.rc1/jasmine.css
• specs/
• SpecHelper.js
• BasicMathSpec.js
• scripts/
• BasicMath.js
http://tryjasmine.com/
describe ... it
describe accepts a
string or class.
Helps in
organizing specs
it is what describes the
spec. It optionally
takes a string
// Jasmine
describe “Calculate”, function() {
describe “#Add”, function(){
it “should give sum”, function(){
-----
-----
};
});
});
Filters
// Jasmine
var calc;
beforeEach(function(){
calc = new Calculator();
});
afterEach(function(){
calc.reset();
});
Pretty handy to create data
for each test
before runs the specified
block before each test.
after runs the specified block
after each test.
Expectations
//Jasmine
it (“should return the sum”, function(){
calc = new Calculator();
expect(calc.Add(4,5).toEqual(9));
expect(calc.Add(4,4).not.toEqual(9));
});
http://tryjasmine.com/
Specs - variables
Spec -
describe('panda',function(){
it('is happy',function(){
expect(panda).toBe('happy');
});
});
JavaScript
panda = “happy”;
Specs - variables
Spec -
describe('panda',function(){
it('is happy',function(){
expect(panda).toBe('happy');
});
});
JavaScript
panda = “happy”;
Specs - functions
Spec
describe('Hello World function',function(){
it('just prints a string',function(){
expect(helloWorld()).toEqual("Hello world!");
});
});
JavaScript
function helloWorld(){
return "Hello world!";
}
Specs –matchers
Spec
describe('Hello World function',function(){
it('just prints a string',function(){
expect(helloWorld()).toContain("world!");
});
});
JavaScript
function helloWorld(){
return "Hello world!";
}
Specs –Custom matchers
Spec
describe('Hello world', function() {
beforeEach(function() {
this.addMatchers({
toBeDivisibleByTwo: function() {
return (this.actual % 2) === 0;
}
});
});
it('is divisible by 2', function() {
expect(guessANumber()).toBeDivisibleByTwo();
});
});
Spy
• Spy are handy in tracking down the usage of dependent or
functions that are being invoked by other functions
• Take a scenario, where on the website I would like to wish the
user like Hi, Hello along with salutation Mr, Ms, Mrs
• Say I have a simple function greet() which returns plain string
• Another function which returns the salutation()
• spyOn(obj, 'method')
• expect(obj.method).toHaveBeenCalled()
Spy - usage
• spyOn(obj, 'method')
• expect(obj.method).toHaveBeenCalled()
• expect(obj.method).toHaveBeenCalled(“Hello”,”Mr”)
• obj.method.callCount
Specs – Spy
describe("User", function() {
it("calls the salutation function", function() {
var visitor = new User();
spyOn(visitor, "greetUser");
visitor.greetUser("Hello");
expect(visitor.greetUser).toHaveBeenCalled();
});
});
Specs – Functions
User = function(){};
User.prototype.greetUser = function(salutation){
return this.sayHello() + "" + salutation;
}
User.prototype.sayHello = function(){
return "Hello";
}
DEMO
What next?
• Spies
• Mocking/Faking
• coffee-script
• jasmine-jquery
• jasmine-fixture
• jasmine-stealth
Thanks
References:
http://blog.bandzarewicz.com/blog/2012/03/08/jasmine-cheat-sheet/
http://evanhahn.com/how-do-i-jasmine/
http://tobyho.com/2011/12/15/jasmine-spy-cheatsheet/
https://github.com/pivotal/jasmine/wiki/Spies

Contenu connexe

Tendances

Capybara testing
Capybara testingCapybara testing
Capybara testingFutureworkz
 
How You Convince Your Manager To Adopt Scala.js in Production
How You Convince Your Manager To Adopt Scala.js in ProductionHow You Convince Your Manager To Adopt Scala.js in Production
How You Convince Your Manager To Adopt Scala.js in ProductionBoldRadius Solutions
 
Microservices: Yes or not?
Microservices: Yes or not?Microservices: Yes or not?
Microservices: Yes or not?Eduard Tomàs
 
Integration Testing with Selenium
Integration Testing with SeleniumIntegration Testing with Selenium
Integration Testing with SeleniumAll Things Open
 
Asp.net mvc 5 course module 1 overview
Asp.net mvc 5 course   module 1 overviewAsp.net mvc 5 course   module 1 overview
Asp.net mvc 5 course module 1 overviewSergey Seletsky
 
Web Performance & Latest in React
Web Performance & Latest in ReactWeb Performance & Latest in React
Web Performance & Latest in ReactTalentica Software
 
Crash Course in AngularJS + Ionic (Deep dive)
Crash Course in AngularJS + Ionic (Deep dive)Crash Course in AngularJS + Ionic (Deep dive)
Crash Course in AngularJS + Ionic (Deep dive)ColdFusionConference
 
2011-02-03 LA RubyConf Rails3 TDD Workshop
2011-02-03 LA RubyConf Rails3 TDD Workshop2011-02-03 LA RubyConf Rails3 TDD Workshop
2011-02-03 LA RubyConf Rails3 TDD WorkshopWolfram Arnold
 
Scal`a`ngular - Scala and Angular
Scal`a`ngular - Scala and AngularScal`a`ngular - Scala and Angular
Scal`a`ngular - Scala and AngularKnoldus Inc.
 
Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0 Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0 Sumanth Chinthagunta
 
Exactpro Systems for KSTU Students in Kostroma
Exactpro Systems for KSTU Students in KostromaExactpro Systems for KSTU Students in Kostroma
Exactpro Systems for KSTU Students in KostromaIosif Itkin
 
Building Massive AngularJS Apps
Building Massive AngularJS AppsBuilding Massive AngularJS Apps
Building Massive AngularJS AppsGordon Bockus
 
Modularize JavaScript with RequireJS
Modularize JavaScript with RequireJSModularize JavaScript with RequireJS
Modularize JavaScript with RequireJSMinh Hoang
 
Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)
Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)
Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)Movel
 
C# Async/Await Explained
C# Async/Await ExplainedC# Async/Await Explained
C# Async/Await ExplainedJeremy Likness
 
Tooling for the productive front-end developer
Tooling for the productive front-end developerTooling for the productive front-end developer
Tooling for the productive front-end developerMaurice De Beijer [MVP]
 
Testing Java EE apps with Arquillian
Testing Java EE apps with ArquillianTesting Java EE apps with Arquillian
Testing Java EE apps with ArquillianIvan Ivanov
 
Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]Ryan Cuprak
 

Tendances (20)

Capybara testing
Capybara testingCapybara testing
Capybara testing
 
How You Convince Your Manager To Adopt Scala.js in Production
How You Convince Your Manager To Adopt Scala.js in ProductionHow You Convince Your Manager To Adopt Scala.js in Production
How You Convince Your Manager To Adopt Scala.js in Production
 
Jbehave selenium
Jbehave seleniumJbehave selenium
Jbehave selenium
 
Microservices: Yes or not?
Microservices: Yes or not?Microservices: Yes or not?
Microservices: Yes or not?
 
Integration Testing with Selenium
Integration Testing with SeleniumIntegration Testing with Selenium
Integration Testing with Selenium
 
Asp.net mvc 5 course module 1 overview
Asp.net mvc 5 course   module 1 overviewAsp.net mvc 5 course   module 1 overview
Asp.net mvc 5 course module 1 overview
 
Angular Unit Testing
Angular Unit TestingAngular Unit Testing
Angular Unit Testing
 
Web Performance & Latest in React
Web Performance & Latest in ReactWeb Performance & Latest in React
Web Performance & Latest in React
 
Crash Course in AngularJS + Ionic (Deep dive)
Crash Course in AngularJS + Ionic (Deep dive)Crash Course in AngularJS + Ionic (Deep dive)
Crash Course in AngularJS + Ionic (Deep dive)
 
2011-02-03 LA RubyConf Rails3 TDD Workshop
2011-02-03 LA RubyConf Rails3 TDD Workshop2011-02-03 LA RubyConf Rails3 TDD Workshop
2011-02-03 LA RubyConf Rails3 TDD Workshop
 
Scal`a`ngular - Scala and Angular
Scal`a`ngular - Scala and AngularScal`a`ngular - Scala and Angular
Scal`a`ngular - Scala and Angular
 
Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0 Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0
 
Exactpro Systems for KSTU Students in Kostroma
Exactpro Systems for KSTU Students in KostromaExactpro Systems for KSTU Students in Kostroma
Exactpro Systems for KSTU Students in Kostroma
 
Building Massive AngularJS Apps
Building Massive AngularJS AppsBuilding Massive AngularJS Apps
Building Massive AngularJS Apps
 
Modularize JavaScript with RequireJS
Modularize JavaScript with RequireJSModularize JavaScript with RequireJS
Modularize JavaScript with RequireJS
 
Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)
Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)
Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)
 
C# Async/Await Explained
C# Async/Await ExplainedC# Async/Await Explained
C# Async/Await Explained
 
Tooling for the productive front-end developer
Tooling for the productive front-end developerTooling for the productive front-end developer
Tooling for the productive front-end developer
 
Testing Java EE apps with Arquillian
Testing Java EE apps with ArquillianTesting Java EE apps with Arquillian
Testing Java EE apps with Arquillian
 
Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]
 

En vedette

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 TestingLars Thorup
 
Intro to testing Javascript with jasmine
Intro to testing Javascript with jasmineIntro to testing Javascript with jasmine
Intro to testing Javascript with jasmineTimothy Oxley
 
Jasmine - why JS tests don't smell fishy
Jasmine - why JS tests don't smell fishyJasmine - why JS tests don't smell fishy
Jasmine - why JS tests don't smell fishyIgor Napierala
 
Unit testing in JavaScript with Jasmine and Karma
Unit testing in JavaScript with Jasmine and KarmaUnit testing in JavaScript with Jasmine and Karma
Unit testing in JavaScript with Jasmine and KarmaAndrey Kolodnitsky
 
JavaScript TDD with Jasmine and Karma
JavaScript TDD with Jasmine and KarmaJavaScript TDD with Jasmine and Karma
JavaScript TDD with Jasmine and KarmaChristopher Bartling
 
JavaScript Firme: Módulos com RequireJS e BDD com Jasmine
JavaScript Firme: Módulos com RequireJS e BDD com JasmineJavaScript Firme: Módulos com RequireJS e BDD com Jasmine
JavaScript Firme: Módulos com RequireJS e BDD com JasmineAndré Willik Valenti
 
DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)
DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)
DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)Dimitar Danailov
 
Behavior Driven Development with AngularJS & Jasmine
Behavior Driven Development with AngularJS & JasmineBehavior Driven Development with AngularJS & Jasmine
Behavior Driven Development with AngularJS & JasmineRemus Langu
 
Quick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmineQuick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmineGil Fink
 
Javascript Testing with Jasmine 101
Javascript Testing with Jasmine 101Javascript Testing with Jasmine 101
Javascript Testing with Jasmine 101Roy Yu
 
Unit testing JavaScript: Jasmine & karma intro
Unit testing JavaScript: Jasmine & karma introUnit testing JavaScript: Jasmine & karma intro
Unit testing JavaScript: Jasmine & karma introMaurice De Beijer [MVP]
 
AngularJS Unit Test
AngularJS Unit TestAngularJS Unit Test
AngularJS Unit TestChiew Carol
 
Jasmine Sandler Client Case Studies- Digital Marketing Consultant - Social Me...
Jasmine Sandler Client Case Studies- Digital Marketing Consultant - Social Me...Jasmine Sandler Client Case Studies- Digital Marketing Consultant - Social Me...
Jasmine Sandler Client Case Studies- Digital Marketing Consultant - Social Me...Jasmine Sandler
 
JAVASCRIPT Test Driven Development & Jasmine
JAVASCRIPT Test Driven Development & JasmineJAVASCRIPT Test Driven Development & Jasmine
JAVASCRIPT Test Driven Development & JasmineAnup Singh
 
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 Christopher Bartling
 
Automated Testing With Jasmine, PhantomJS and Jenkins
Automated Testing With Jasmine, PhantomJS and JenkinsAutomated Testing With Jasmine, PhantomJS and Jenkins
Automated Testing With Jasmine, PhantomJS and JenkinsWork at Play
 

En vedette (20)

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
 
Jasmine BDD for Javascript
Jasmine BDD for JavascriptJasmine BDD for Javascript
Jasmine BDD for Javascript
 
Intro to testing Javascript with jasmine
Intro to testing Javascript with jasmineIntro to testing Javascript with jasmine
Intro to testing Javascript with jasmine
 
Jasmine - why JS tests don't smell fishy
Jasmine - why JS tests don't smell fishyJasmine - why JS tests don't smell fishy
Jasmine - why JS tests don't smell fishy
 
Unit testing in JavaScript with Jasmine and Karma
Unit testing in JavaScript with Jasmine and KarmaUnit testing in JavaScript with Jasmine and Karma
Unit testing in JavaScript with Jasmine and Karma
 
Karma - JS Test Runner
Karma - JS Test RunnerKarma - JS Test Runner
Karma - JS Test Runner
 
JavaScript TDD with Jasmine and Karma
JavaScript TDD with Jasmine and KarmaJavaScript TDD with Jasmine and Karma
JavaScript TDD with Jasmine and Karma
 
JavaScript Firme: Módulos com RequireJS e BDD com Jasmine
JavaScript Firme: Módulos com RequireJS e BDD com JasmineJavaScript Firme: Módulos com RequireJS e BDD com Jasmine
JavaScript Firme: Módulos com RequireJS e BDD com Jasmine
 
Behavior Driven GUI Testing
Behavior Driven GUI TestingBehavior Driven GUI Testing
Behavior Driven GUI Testing
 
DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)
DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)
DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)
 
Behavior Driven Development with AngularJS & Jasmine
Behavior Driven Development with AngularJS & JasmineBehavior Driven Development with AngularJS & Jasmine
Behavior Driven Development with AngularJS & Jasmine
 
Quick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmineQuick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmine
 
Javascript Testing with Jasmine 101
Javascript Testing with Jasmine 101Javascript Testing with Jasmine 101
Javascript Testing with Jasmine 101
 
Unit testing JavaScript: Jasmine & karma intro
Unit testing JavaScript: Jasmine & karma introUnit testing JavaScript: Jasmine & karma intro
Unit testing JavaScript: Jasmine & karma intro
 
AngularJS Unit Test
AngularJS Unit TestAngularJS Unit Test
AngularJS Unit Test
 
Jasmine Sandler Client Case Studies- Digital Marketing Consultant - Social Me...
Jasmine Sandler Client Case Studies- Digital Marketing Consultant - Social Me...Jasmine Sandler Client Case Studies- Digital Marketing Consultant - Social Me...
Jasmine Sandler Client Case Studies- Digital Marketing Consultant - Social Me...
 
JAVASCRIPT Test Driven Development & Jasmine
JAVASCRIPT Test Driven Development & JasmineJAVASCRIPT Test Driven Development & Jasmine
JAVASCRIPT Test Driven Development & Jasmine
 
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
 
jasmine
jasminejasmine
jasmine
 
Automated Testing With Jasmine, PhantomJS and Jenkins
Automated Testing With Jasmine, PhantomJS and JenkinsAutomated Testing With Jasmine, PhantomJS and Jenkins
Automated Testing With Jasmine, PhantomJS and Jenkins
 

Similaire à Jasmine - A BDD test framework for JavaScript

Lean-Agile Development with SharePoint - Bill Ayers
Lean-Agile Development with SharePoint - Bill AyersLean-Agile Development with SharePoint - Bill Ayers
Lean-Agile Development with SharePoint - Bill AyersSPC Adriatics
 
How to write test in node.js
How to write test in node.jsHow to write test in node.js
How to write test in node.jsJason Lin
 
Que nos espera a los ALM Dudes para el 2013?
Que nos espera a los ALM Dudes para el 2013?Que nos espera a los ALM Dudes para el 2013?
Que nos espera a los ALM Dudes para el 2013?Bruno Capuano
 
From Pilot to Product - Morning@Lohika
From Pilot to Product - Morning@LohikaFrom Pilot to Product - Morning@Lohika
From Pilot to Product - Morning@LohikaIvan Verhun
 
Introduction to Test Driven Development
Introduction to Test Driven DevelopmentIntroduction to Test Driven Development
Introduction to Test Driven DevelopmentSarah Dutkiewicz
 
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
 
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
 
How to Use Selenium, Successfully
How to Use Selenium, SuccessfullyHow to Use Selenium, Successfully
How to Use Selenium, SuccessfullySauce Labs
 
Ast in CI/CD by Ofer Maor
Ast in CI/CD by Ofer MaorAst in CI/CD by Ofer Maor
Ast in CI/CD by Ofer MaorDevSecCon
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium SuccessfullyDave Haeffner
 
Bringing DevOps to the Database
Bringing DevOps to the DatabaseBringing DevOps to the Database
Bringing DevOps to the DatabaseMichaela Murray
 
Introduction to Testing and TDD
Introduction to Testing and TDDIntroduction to Testing and TDD
Introduction to Testing and TDDSarah Dutkiewicz
 
Dbops, DevOps & Ops, by Eduardo Piairo
Dbops, DevOps & Ops, by Eduardo PiairoDbops, DevOps & Ops, by Eduardo Piairo
Dbops, DevOps & Ops, by Eduardo PiairoAgile Connect®
 
Vibe Custom Development
Vibe Custom DevelopmentVibe Custom Development
Vibe Custom DevelopmentGWAVA
 
What is this agile thing anyway
What is this agile thing anywayWhat is this agile thing anyway
What is this agile thing anywayLisa Van Gelder
 
Create Your Own Starter Files
Create Your Own Starter FilesCreate Your Own Starter Files
Create Your Own Starter FilesEmily Lewis
 
Understanding TDD - theory, practice, techniques and tips.
Understanding TDD - theory, practice, techniques and tips.Understanding TDD - theory, practice, techniques and tips.
Understanding TDD - theory, practice, techniques and tips.Malinda Kapuruge
 

Similaire à Jasmine - A BDD test framework for JavaScript (20)

Lean-Agile Development with SharePoint - Bill Ayers
Lean-Agile Development with SharePoint - Bill AyersLean-Agile Development with SharePoint - Bill Ayers
Lean-Agile Development with SharePoint - Bill Ayers
 
How to write test in node.js
How to write test in node.jsHow to write test in node.js
How to write test in node.js
 
Que nos espera a los ALM Dudes para el 2013?
Que nos espera a los ALM Dudes para el 2013?Que nos espera a los ALM Dudes para el 2013?
Que nos espera a los ALM Dudes para el 2013?
 
From Pilot to Product - Morning@Lohika
From Pilot to Product - Morning@LohikaFrom Pilot to Product - Morning@Lohika
From Pilot to Product - Morning@Lohika
 
Introduction to Test Driven Development
Introduction to Test Driven DevelopmentIntroduction to Test Driven Development
Introduction to Test Driven Development
 
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...
 
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...
 
How to Use Selenium, Successfully
How to Use Selenium, SuccessfullyHow to Use Selenium, Successfully
How to Use Selenium, Successfully
 
Ast in CI/CD by Ofer Maor
Ast in CI/CD by Ofer MaorAst in CI/CD by Ofer Maor
Ast in CI/CD by Ofer Maor
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium Successfully
 
Miami2015
Miami2015Miami2015
Miami2015
 
Bringing DevOps to the Database
Bringing DevOps to the DatabaseBringing DevOps to the Database
Bringing DevOps to the Database
 
Tdd
TddTdd
Tdd
 
Introduction to Testing and TDD
Introduction to Testing and TDDIntroduction to Testing and TDD
Introduction to Testing and TDD
 
Dbops, DevOps & Ops, by Eduardo Piairo
Dbops, DevOps & Ops, by Eduardo PiairoDbops, DevOps & Ops, by Eduardo Piairo
Dbops, DevOps & Ops, by Eduardo Piairo
 
introduction v4
introduction v4introduction v4
introduction v4
 
Vibe Custom Development
Vibe Custom DevelopmentVibe Custom Development
Vibe Custom Development
 
What is this agile thing anyway
What is this agile thing anywayWhat is this agile thing anyway
What is this agile thing anyway
 
Create Your Own Starter Files
Create Your Own Starter FilesCreate Your Own Starter Files
Create Your Own Starter Files
 
Understanding TDD - theory, practice, techniques and tips.
Understanding TDD - theory, practice, techniques and tips.Understanding TDD - theory, practice, techniques and tips.
Understanding TDD - theory, practice, techniques and tips.
 

Plus de Sumanth krishna

Scope demystified - AngularJS
Scope demystified - AngularJSScope demystified - AngularJS
Scope demystified - AngularJSSumanth krishna
 
Services Factory Provider Value Constant - AngularJS
Services Factory Provider Value Constant - AngularJSServices Factory Provider Value Constant - AngularJS
Services Factory Provider Value Constant - AngularJSSumanth krishna
 
Ruby Interview Questions
Ruby Interview QuestionsRuby Interview Questions
Ruby Interview QuestionsSumanth krishna
 
Ruby on Rails industry trends
Ruby on Rails industry trendsRuby on Rails industry trends
Ruby on Rails industry trendsSumanth krishna
 
Introducing Ruby/MVC/RoR
Introducing Ruby/MVC/RoRIntroducing Ruby/MVC/RoR
Introducing Ruby/MVC/RoRSumanth krishna
 
Watir Presentation Sumanth Krishna. A
Watir Presentation   Sumanth Krishna. AWatir Presentation   Sumanth Krishna. A
Watir Presentation Sumanth Krishna. ASumanth krishna
 
Ro R Based Social Networking Apps Compared
Ro R Based Social Networking Apps ComparedRo R Based Social Networking Apps Compared
Ro R Based Social Networking Apps ComparedSumanth krishna
 
New Rabbit Tortoise Story
New Rabbit   Tortoise StoryNew Rabbit   Tortoise Story
New Rabbit Tortoise StorySumanth krishna
 
RoR relevance to startups Session @ Barcamp5 - Sumanth Krishna
RoR relevance to startups Session @ Barcamp5 - Sumanth KrishnaRoR relevance to startups Session @ Barcamp5 - Sumanth Krishna
RoR relevance to startups Session @ Barcamp5 - Sumanth KrishnaSumanth krishna
 
How Brain Works against in identifying colors?
How Brain Works against in identifying colors?How Brain Works against in identifying colors?
How Brain Works against in identifying colors?Sumanth krishna
 

Plus de Sumanth krishna (13)

Scope demystified - AngularJS
Scope demystified - AngularJSScope demystified - AngularJS
Scope demystified - AngularJS
 
Services Factory Provider Value Constant - AngularJS
Services Factory Provider Value Constant - AngularJSServices Factory Provider Value Constant - AngularJS
Services Factory Provider Value Constant - AngularJS
 
Ruby Interview Questions
Ruby Interview QuestionsRuby Interview Questions
Ruby Interview Questions
 
Ruby on Rails industry trends
Ruby on Rails industry trendsRuby on Rails industry trends
Ruby on Rails industry trends
 
Introducing Ruby/MVC/RoR
Introducing Ruby/MVC/RoRIntroducing Ruby/MVC/RoR
Introducing Ruby/MVC/RoR
 
Watir Presentation Sumanth Krishna. A
Watir Presentation   Sumanth Krishna. AWatir Presentation   Sumanth Krishna. A
Watir Presentation Sumanth Krishna. A
 
Life Pencil And U
Life Pencil And ULife Pencil And U
Life Pencil And U
 
Ro R Based Social Networking Apps Compared
Ro R Based Social Networking Apps ComparedRo R Based Social Networking Apps Compared
Ro R Based Social Networking Apps Compared
 
Put The Glass Down
Put The Glass DownPut The Glass Down
Put The Glass Down
 
New Rabbit Tortoise Story
New Rabbit   Tortoise StoryNew Rabbit   Tortoise Story
New Rabbit Tortoise Story
 
RoR relevance to startups Session @ Barcamp5 - Sumanth Krishna
RoR relevance to startups Session @ Barcamp5 - Sumanth KrishnaRoR relevance to startups Session @ Barcamp5 - Sumanth Krishna
RoR relevance to startups Session @ Barcamp5 - Sumanth Krishna
 
Cookie - story
Cookie - storyCookie - story
Cookie - story
 
How Brain Works against in identifying colors?
How Brain Works against in identifying colors?How Brain Works against in identifying colors?
How Brain Works against in identifying colors?
 

Dernier

Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
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
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
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
 

Dernier (20)

Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
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
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
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
 

Jasmine - A BDD test framework for JavaScript

  • 2. Agenda • Need of TDD/BDD • Steps to BDD • Familiarize terminology • Installation • Executing jasmine • Write tests in jasmine • What next?
  • 3. TDD • Involves writing tests before writing the code being tested • Write a small test first (at this point of time no code being written!) • Run the test (obviously, it fails!) • Now make the test pass (well write some code) • Observe the design, refactor
  • 4. TDD - Challenges • As the code size increases more refactor becomes critical • Since most of the time the features are not pre- determined reviewing/refactoring does prove as time consuming and becomes expensive
  • 5. So what next??? • In real time objects are the carriers • They extend the behavior of classes • This would be mean, “what an object does is significantly more important!” • It’s all behavior
  • 6. BDD • Behaviour Driven Development is an Agile development process that comprises aspects of – Acceptance Test Driven Planning, – Domain Driven Design – Test Driven Development
  • 7. BDD • BDD puts the focus on Behavior rather than structure • Examples – User inputting values – Awaiting for the feedback – Calculations/logic • It’s all behavior
  • 8. BDD Triad • For better communication across the levels (Business analysts, Developers, Testers) in software development we narrate/describe the logical chunks as scenarios • Given/When/Then – called as BDD triad
  • 11. Jasmine • It’s a BDD Framework for testing JavaScript • Does not depend on other frameworks • Does not require a DOM • Clean & Obvious syntax • Influenced by Rspec, JSSpec, Jspec • Available as stand-alone, ruby gem, Node.js module, as Maven plugin
  • 12. Principles • Should not be tied to any browser, framework, platform or host language • Should have idiomatic and unsurprising syntax • Should work wherever JavaScript runs • Should play well with IDE’s
  • 13. Goals • It should encourage good testing practices • It should be simple to get start with • It should integrate easily with continuous build systems
  • 15. Installation •Required files/structure •Download stand alone zip file include the lib files <script type="text/javascript" src="lib/jasmine-1.0.0.rc1/jasmine.js"></script>   <script type="text/javascript" src="lib/jasmine-1.0.0.rc1/jasmine-html.js"></script>   •Include styles as well <link rel="stylesheet" type="text/css" href="lib/jasmine-1.0.0.rc1/jasmine.css">
  • 16. Implementation/File structure •jasmine-example/ • lib/ • jasmine-1.3.1/jasmine.js • jasmine-1.3.1/jasmine-html.js • jasmine-1.0.0.rc1/jasmine.css • specs/ • SpecHelper.js • BasicMathSpec.js • scripts/ • BasicMath.js
  • 18. describe ... it describe accepts a string or class. Helps in organizing specs it is what describes the spec. It optionally takes a string // Jasmine describe “Calculate”, function() { describe “#Add”, function(){ it “should give sum”, function(){ ----- ----- }; }); });
  • 19. Filters // Jasmine var calc; beforeEach(function(){ calc = new Calculator(); }); afterEach(function(){ calc.reset(); }); Pretty handy to create data for each test before runs the specified block before each test. after runs the specified block after each test.
  • 20. Expectations //Jasmine it (“should return the sum”, function(){ calc = new Calculator(); expect(calc.Add(4,5).toEqual(9)); expect(calc.Add(4,4).not.toEqual(9)); });
  • 22. Specs - variables Spec - describe('panda',function(){ it('is happy',function(){ expect(panda).toBe('happy'); }); }); JavaScript panda = “happy”;
  • 23. Specs - variables Spec - describe('panda',function(){ it('is happy',function(){ expect(panda).toBe('happy'); }); }); JavaScript panda = “happy”;
  • 24. Specs - functions Spec describe('Hello World function',function(){ it('just prints a string',function(){ expect(helloWorld()).toEqual("Hello world!"); }); }); JavaScript function helloWorld(){ return "Hello world!"; }
  • 25. Specs –matchers Spec describe('Hello World function',function(){ it('just prints a string',function(){ expect(helloWorld()).toContain("world!"); }); }); JavaScript function helloWorld(){ return "Hello world!"; }
  • 26. Specs –Custom matchers Spec describe('Hello world', function() { beforeEach(function() { this.addMatchers({ toBeDivisibleByTwo: function() { return (this.actual % 2) === 0; } }); }); it('is divisible by 2', function() { expect(guessANumber()).toBeDivisibleByTwo(); }); });
  • 27. Spy • Spy are handy in tracking down the usage of dependent or functions that are being invoked by other functions • Take a scenario, where on the website I would like to wish the user like Hi, Hello along with salutation Mr, Ms, Mrs • Say I have a simple function greet() which returns plain string • Another function which returns the salutation() • spyOn(obj, 'method') • expect(obj.method).toHaveBeenCalled()
  • 28. Spy - usage • spyOn(obj, 'method') • expect(obj.method).toHaveBeenCalled() • expect(obj.method).toHaveBeenCalled(“Hello”,”Mr”) • obj.method.callCount
  • 29. Specs – Spy describe("User", function() { it("calls the salutation function", function() { var visitor = new User(); spyOn(visitor, "greetUser"); visitor.greetUser("Hello"); expect(visitor.greetUser).toHaveBeenCalled(); }); });
  • 30. Specs – Functions User = function(){}; User.prototype.greetUser = function(salutation){ return this.sayHello() + "" + salutation; } User.prototype.sayHello = function(){ return "Hello"; }
  • 31. DEMO
  • 32. What next? • Spies • Mocking/Faking • coffee-script • jasmine-jquery • jasmine-fixture • jasmine-stealth