SlideShare ist ein Scribd-Unternehmen logo
1 von 54
Tobias Bosch & Stefan Scheidt/ OPITZ CONSULTING GmbH Test-Driven JavaScript Development
Wer sind wir? tobias.bosch@opitz-consulting.com (@tigbro) stefan.scheidt@opitz-consulting.com (@beezlebug)
Wer sind Sie?
In diesem Vortrag geht‘s um... ...automatisiertes Testen ...durch Entwickler
Warum testen?
Warum JavaScript-Code testen?
Laufzeitumgebungen für JavaScript ...
In diesem Vortrag: Icon Set by Paul Irish (http://paulirish.com/2010/high-res-browser-icons/)
Tests formulieren
„Klassisch“ mit xUnit-Asserts „BDD-Style“  à la RSpec
Demo: BDD mit Jasmine
describe("parseFloat", function() { it("shouldreturnundefinedforundefined", function () { expect(util.parseFloat(undefined)).toBeUndefined();     }); it("shouldreturn 0 foremptystring", function () { expect(util.parseFloat('')).toEqual(0);     }); it("shouldreturnnumberfornumberstrings", function () { expect(util.parseFloat('1.5')).toEqual(1.5);     });     // ... }); Hello Jasmine!
describe("parseFloat", function() { it("shouldreturnundefinedforundefined", function () { expect(util.parseFloat(undefined)).toBeUndefined();     }); it("shouldreturn 0 foremptystring", function () { expect(util.parseFloat('')).toEqual(0);     }); it("shouldreturnnumberfornumberstrings", function () { expect(util.parseFloat('1.5')).toEqual(1.5);     });     // ... }); Hello Jasmine! Suite
describe("parseFloat", function() { it("shouldreturnundefinedforundefined", function () { expect(util.parseFloat(undefined)).toBeUndefined(); }); it("shouldreturn 0 foremptystring", function () { expect(util.parseFloat('')).toEqual(0);   }); it("shouldreturnnumberfornumberstrings", function () { expect(util.parseFloat('1.5')).toEqual(1.5);  });     // ... }); Hello Jasmine! Specs
describe("parseFloat", function() { it("shouldreturnundefinedforundefined", function () { expect(util.parseFloat(undefined)).toBeUndefined();     }); it("shouldreturn 0 foremptystring", function () { expect(util.parseFloat('')).toEqual(0);     }); it("shouldreturnnumberfornumberstrings", function () { expect(util.parseFloat('1.5')).toEqual(1.5);     });     // ... }); Hello Jasmine! Matcher
Hello Jasmine! expect(x).toEqual(y); expect(x).toBe(y); expect(x).toBeDefined(); expect(x).toBeUndefined(); expect(x).toBeTruthy(); expect(x).toBeFalsy(); ... Matcher
Hello Jasmine! Spec Runner
Fortgeschrittene Konzepte
Spies
Spies describe("execute fadein", function() {     it("should eventually set opacity to 1", function () { varelement = document.createElement("div"); spyOn(window, 'setTimeout').andCallFake(             function(callback) {               callback();       }); spyOn(util, 'opacity'); fadein.execute(element);       expect(util.opacity.mostRecentCall.args[1]).toEqual(1);   }); });
Spies describe("execute fadein", function() {     it("should eventually set opacity to 1", function () { varelement = document.createElement("div"); spyOn(window, 'setTimeout').andCallFake(             function(callback) {               callback();       }); spyOn(util, 'opacity'); fadein.execute(element);       expect(util.opacity.mostRecentCall.args[1]).toEqual(1);   }); });
Spies describe("execute fadein", function() {     it("should eventually set opacity to 1", function () { varelement = document.createElement("div"); spyOn(window, 'setTimeout').andCallFake(             function(callback) {               callback();       }); spyOn(util, 'opacity'); fadein.execute(element);       expect(util.opacity.mostRecentCall.args[1]).toEqual(1);   }); }); Arrange
Spies describe("execute fadein", function() {     it("should eventually set opacity to 1", function () { varelement = document.createElement("div"); spyOn(window, 'setTimeout').andCallFake(             function(callback) {               callback();       }); spyOn(util, 'opacity'); fadein.execute(element);       expect(util.opacity.mostRecentCall.args[1]).toEqual(1);   }); }); Arrange // waitsfor 'delay' seconds // thencallscallback window.setTimeout = function (callback, delay) {     ... };
Spies describe("execute fadein", function() {     it("should eventually set opacity to 1", function () { varelement = document.createElement("div"); spyOn(window, 'setTimeout').andCallFake(             function(callback) {               callback();       }); spyOn(util, 'opacity'); fadein.execute(element);       expect(util.opacity.mostRecentCall.args[1]).toEqual(1);   }); }); Arrange // setopacityof 'element' to 'opacity' util.opacity = function (element, opacity) {     ... };
Spies describe("execute fadein", function() {     it("should eventually set opacity to 1", function () { varelement = document.createElement("div"); spyOn(window, 'setTimeout').andCallFake(             function(callback) {               callback();       }); spyOn(util, 'opacity'); fadein.execute(element);       expect(util.opacity.mostRecentCall.args[1]).toEqual(1);   }); }); Act
Spies describe("execute fadein", function() {     it("should eventually set opacity to 1", function () { varelement = document.createElement("div"); spyOn(window, 'setTimeout').andCallFake(             function(callback) {               callback();       }); spyOn(util, 'opacity'); fadein.execute(element);       expect(util.opacity.mostRecentCall.args[1]).toEqual(1);   }); }); // setopacityof 'element' to 'opacity' util.opacity = function (element, opacity) {     ... };  Assert
Funktionen von Spies
Matcher für Spies Eigenschaften von Spies
Asynchrone Tests
it("should eventually set opacity to 1", function() { var element = document.createElement("div"); spyOn(util, 'opacity');     runs(function() { fadein.execute(element); }); waitsFor(function () {         return opacitySpy.mostRecentCall.args[1] === 1; }); runs(function() {     // some other expectations         expect(opacitySpy.mostRecentCall.args[1]).toEqual(1);      }); }); Asynchrone Tests
it("should eventually set opacity to 1", function() { var element = document.createElement("div"); spyOn(util, 'opacity');     runs(function() { fadein.execute(element); }); waitsFor(function () {         return opacitySpy.mostRecentCall.args[1] === 1; }); runs(function() {     // some other expectations         expect(opacitySpy.mostRecentCall.args[1]).toEqual(1);      }); }); Asynchrone Tests Arrange
it("should eventually set opacity to 1", function() { var element = document.createElement("div"); spyOn(util, 'opacity');     runs(function() { fadein.execute(element); }); waitsFor(function () {         return opacitySpy.mostRecentCall.args[1] === 1; }); runs(function() {     // some other expectations         expect(opacitySpy.mostRecentCall.args[1]).toEqual(1);      }); }); Asynchrone Tests Act
it("should eventually set opacity to 1", function() { var element = document.createElement("div"); spyOn(util, 'opacity');     runs(function() { fadein.execute(element); }); waitsFor(function () {         return opacitySpy.mostRecentCall.args[1] === 1; }); runs(function() {     // some other expectations         expect(opacitySpy.mostRecentCall.args[1]).toEqual(1);      }); }); Asynchrone Tests Wait... // setopacityof 'element' to 'opacity' util.opacity = function (element, opacity) {     ... };
it("should eventually set opacity to 1", function() { var element = document.createElement("div"); spyOn(util, 'opacity');     runs(function() { fadein.execute(element); }); waitsFor(function () {         return opacitySpy.mostRecentCall.args[1] === 1; }); runs(function() {     // some other expectations         expect(opacitySpy.mostRecentCall.args[1]).toEqual(1);      }); }); Asynchrone Tests Assert
UI-Tests
it("should fade in hello div on buttonclick", function () { varwin, field, button; loadHtml("/js-fadein/index.html"); runs(function() { win = testwindow(); field = win.document.getElementById('hello'); button = win.document.getElementById('fadein');     }); runs(function () { expect(win.util.opacity(field)).toEqual(0); jasmine.ui.simulate(button, 'click');     }); waitsForAsync(); runs(function () { expect(win.util.opacity(field)).toEqual(1);     }); }); UI-Test mit Jasmine-UI
it("should fade in hello div on buttonclick", function () { varwin, field, button; loadHtml("/js-fadein/index.html"); runs(function() { win = testwindow(); field = win.document.getElementById('hello'); button = win.document.getElementById('fadein');     }); runs(function () { expect(win.util.opacity(field)).toEqual(0); jasmine.ui.simulate(button, 'click');     }); waitsForAsync(); runs(function () { expect(win.util.opacity(field)).toEqual(1);     }); }); The indexpage... UI-Test mit Jasmine-UI
it("should fade in hello div on buttonclick", function () { varwin, field, button; loadHtml("/js-fadein/index.html"); runs(function() { win = testwindow(); field = win.document.getElementById('hello'); button = win.document.getElementById('fadein');     }); runs(function () { expect(win.util.opacity(field)).toEqual(0); jasmine.ui.simulate(button, 'click');     }); waitsForAsync(); runs(function () { expect(win.util.opacity(field)).toEqual(1);     }); }); Arrange, Part 1 UI-Test mit Jasmine-UI
it("should fade in hello div on buttonclick", function () { varwin, field, button; loadHtml("/js-fadein/index.html"); runs(function() { win = testwindow(); field = win.document.getElementById('hello'); button = win.document.getElementById('fadein');     }); runs(function () { expect(win.util.opacity(field)).toEqual(0); jasmine.ui.simulate(button, 'click');     }); waitsForAsync(); runs(function () { expect(win.util.opacity(field)).toEqual(1);     }); }); Arrange, Part 2 UI-Test mit Jasmine-UI
it("should fade in hello div on buttonclick", function () { varwin, field, button; loadHtml("/js-fadein/index.html"); runs(function() { win = testwindow(); field = win.document.getElementById('hello'); button = win.document.getElementById('fadein');     }); runs(function () { expect(win.util.opacity(field)).toEqual(0); jasmine.ui.simulate(button, 'click');     }); waitsForAsync(); runs(function () { expect(win.util.opacity(field)).toEqual(1);     }); }); Act UI-Test mit Jasmine-UI
it("should fade in hello div on buttonclick", function () { varwin, field, button; loadHtml("/js-fadein/index.html"); runs(function() { win = testwindow(); field = win.document.getElementById('hello'); button = win.document.getElementById('fadein');     }); runs(function () { expect(win.util.opacity(field)).toEqual(0); jasmine.ui.simulate(button, 'click');     }); waitsForAsync(); runs(function () { expect(win.util.opacity(field)).toEqual(1);     }); }); Wait... UI-Test mit Jasmine-UI
it("should fade in hello div on buttonclick", function () { varwin, field, button; loadHtml("/js-fadein/index.html"); runs(function() { win = testwindow(); field = win.document.getElementById('hello'); button = win.document.getElementById('fadein');     }); runs(function () { expect(win.util.opacity(field)).toEqual(0); jasmine.ui.simulate(button, 'click');     }); waitsForAsync(); runs(function () { expect(win.util.opacity(field)).toEqual(1);     }); }); Assert UI-Test mit Jasmine-UI
Testausführung automatisieren
Browser fernsteuern
JsTestDriver http://code.google.com/p/js-test-driver/
Demo: JsTestDriver
Fazit Es gibt ein umfangreiches Toolset zum Testen von JavaScript-Code. Testen Sie Ihren Code! Testen Sie insbesondere Ihren JavaScript-Code! Sie haben keine Ausrede...
Links
saturatedwriting (ByEduordo, http://www.flickr.com/photos/tnarik/366393127/) Smiley Keyboard (By~Prescott, http://www.flickr.com/photos/ppym1/93571524/) Spyhole, Paris (Bysmithofsmiths, http://www.flickr.com/photos/hesketh/232015302/) Sortasynchroniseddiving (By Aaron Retz, http://www.flickr.com/photos/aretz/309469339/)
StampCollector (ByC. Castillo, http://www.flickr.com/photos/carolinedecastillo/2750577684/) bios[bible] (ByGastev, http://www.flickr.com/photos/gastev/2174505811/) Day 276/365: in hotpursuit (By Tina Vega, http://www.flickr.com/photos/tinavega/3066602429/)
Vielen Dankfür Ihr Interesse!@tigbro@beezlebug

Weitere ähnliche Inhalte

Was ist angesagt?

Redux Sagas - React Alicante
Redux Sagas - React AlicanteRedux Sagas - React Alicante
Redux Sagas - React AlicanteIgnacio Martín
 
AngularJS Testing Strategies
AngularJS Testing StrategiesAngularJS Testing Strategies
AngularJS Testing Strategiesnjpst8
 
Workshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScriptWorkshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScriptVisual Engineering
 
Introduction to Functional Programming (w/ JS)
Introduction to Functional Programming (w/ JS)Introduction to Functional Programming (w/ JS)
Introduction to Functional Programming (w/ JS)Allan Marques Baptista
 
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6FrontDays
 
Using Redux-Saga for Handling Side Effects
Using Redux-Saga for Handling Side EffectsUsing Redux-Saga for Handling Side Effects
Using Redux-Saga for Handling Side EffectsGlobalLogic Ukraine
 
Test driven node.js
Test driven node.jsTest driven node.js
Test driven node.jsJay Harris
 
Коварный code type ITGM #9
Коварный code type ITGM #9Коварный code type ITGM #9
Коварный code type ITGM #9Andrey Zakharevich
 
Introduction to CDI and DI in Java EE 6
Introduction to CDI and DI in Java EE 6Introduction to CDI and DI in Java EE 6
Introduction to CDI and DI in Java EE 6Ray Ploski
 
Djangocon11: Monkeying around at New Relic
Djangocon11: Monkeying around at New RelicDjangocon11: Monkeying around at New Relic
Djangocon11: Monkeying around at New RelicNew Relic
 
Functions, Types, Programs and Effects
Functions, Types, Programs and EffectsFunctions, Types, Programs and Effects
Functions, Types, Programs and EffectsRaymond Roestenburg
 
The algebra of library design
The algebra of library designThe algebra of library design
The algebra of library designLeonardo Borges
 
Thirteen ways of looking at a turtle
Thirteen ways of looking at a turtleThirteen ways of looking at a turtle
Thirteen ways of looking at a turtleScott Wlaschin
 
To Err Is Human
To Err Is HumanTo Err Is Human
To Err Is HumanAlex Liu
 
Impress Your Friends with EcmaScript 2015
Impress Your Friends with EcmaScript 2015Impress Your Friends with EcmaScript 2015
Impress Your Friends with EcmaScript 2015Lukas Ruebbelke
 
Zope component architechture
Zope component architechtureZope component architechture
Zope component architechtureAnatoly Bubenkov
 

Was ist angesagt? (20)

Redux Sagas - React Alicante
Redux Sagas - React AlicanteRedux Sagas - React Alicante
Redux Sagas - React Alicante
 
Testing AngularJS
Testing AngularJSTesting AngularJS
Testing AngularJS
 
Akka tips
Akka tipsAkka tips
Akka tips
 
AngularJS Testing Strategies
AngularJS Testing StrategiesAngularJS Testing Strategies
AngularJS Testing Strategies
 
Workshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScriptWorkshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScript
 
Introduction to Functional Programming (w/ JS)
Introduction to Functional Programming (w/ JS)Introduction to Functional Programming (w/ JS)
Introduction to Functional Programming (w/ JS)
 
Con5623 pdf 5623_001
Con5623 pdf 5623_001Con5623 pdf 5623_001
Con5623 pdf 5623_001
 
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6
 
Using Redux-Saga for Handling Side Effects
Using Redux-Saga for Handling Side EffectsUsing Redux-Saga for Handling Side Effects
Using Redux-Saga for Handling Side Effects
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
 
Test driven node.js
Test driven node.jsTest driven node.js
Test driven node.js
 
Коварный code type ITGM #9
Коварный code type ITGM #9Коварный code type ITGM #9
Коварный code type ITGM #9
 
Introduction to CDI and DI in Java EE 6
Introduction to CDI and DI in Java EE 6Introduction to CDI and DI in Java EE 6
Introduction to CDI and DI in Java EE 6
 
Djangocon11: Monkeying around at New Relic
Djangocon11: Monkeying around at New RelicDjangocon11: Monkeying around at New Relic
Djangocon11: Monkeying around at New Relic
 
Functions, Types, Programs and Effects
Functions, Types, Programs and EffectsFunctions, Types, Programs and Effects
Functions, Types, Programs and Effects
 
The algebra of library design
The algebra of library designThe algebra of library design
The algebra of library design
 
Thirteen ways of looking at a turtle
Thirteen ways of looking at a turtleThirteen ways of looking at a turtle
Thirteen ways of looking at a turtle
 
To Err Is Human
To Err Is HumanTo Err Is Human
To Err Is Human
 
Impress Your Friends with EcmaScript 2015
Impress Your Friends with EcmaScript 2015Impress Your Friends with EcmaScript 2015
Impress Your Friends with EcmaScript 2015
 
Zope component architechture
Zope component architechtureZope component architechture
Zope component architechture
 

Andere mochten auch

Smmms for chamber
Smmms for chamberSmmms for chamber
Smmms for chamberLizBESocial
 
Luis Gutiérrez - SIBRT - Trabajando Juntos por un Transporte Público de Alta ...
Luis Gutiérrez - SIBRT - Trabajando Juntos por un Transporte Público de Alta ...Luis Gutiérrez - SIBRT - Trabajando Juntos por un Transporte Público de Alta ...
Luis Gutiérrez - SIBRT - Trabajando Juntos por un Transporte Público de Alta ...Fagner Glinski
 
Nordnetin tuloskausietkot 21.7.2015
Nordnetin tuloskausietkot 21.7.2015Nordnetin tuloskausietkot 21.7.2015
Nordnetin tuloskausietkot 21.7.2015Nordnet Suomi
 
Festival customers - workshop poster
Festival customers - workshop posterFestival customers - workshop poster
Festival customers - workshop posterfestivalslab
 
Simple Strategies of Email Marketing
Simple Strategies of Email Marketing Simple Strategies of Email Marketing
Simple Strategies of Email Marketing LizBESocial
 
iOS Einstieg und Ausblick - Mobile DevCon 2011 - OPITZ CONSULTING -Stefan Sch...
iOS Einstieg und Ausblick - Mobile DevCon 2011 - OPITZ CONSULTING -Stefan Sch...iOS Einstieg und Ausblick - Mobile DevCon 2011 - OPITZ CONSULTING -Stefan Sch...
iOS Einstieg und Ausblick - Mobile DevCon 2011 - OPITZ CONSULTING -Stefan Sch...OPITZ CONSULTING Deutschland
 

Andere mochten auch (7)

Smmms for chamber
Smmms for chamberSmmms for chamber
Smmms for chamber
 
Luis Gutiérrez - SIBRT - Trabajando Juntos por un Transporte Público de Alta ...
Luis Gutiérrez - SIBRT - Trabajando Juntos por un Transporte Público de Alta ...Luis Gutiérrez - SIBRT - Trabajando Juntos por un Transporte Público de Alta ...
Luis Gutiérrez - SIBRT - Trabajando Juntos por un Transporte Público de Alta ...
 
Nordnetin tuloskausietkot 21.7.2015
Nordnetin tuloskausietkot 21.7.2015Nordnetin tuloskausietkot 21.7.2015
Nordnetin tuloskausietkot 21.7.2015
 
Festival customers - workshop poster
Festival customers - workshop posterFestival customers - workshop poster
Festival customers - workshop poster
 
Simple Strategies of Email Marketing
Simple Strategies of Email Marketing Simple Strategies of Email Marketing
Simple Strategies of Email Marketing
 
iOS Einstieg und Ausblick - Mobile DevCon 2011 - OPITZ CONSULTING -Stefan Sch...
iOS Einstieg und Ausblick - Mobile DevCon 2011 - OPITZ CONSULTING -Stefan Sch...iOS Einstieg und Ausblick - Mobile DevCon 2011 - OPITZ CONSULTING -Stefan Sch...
iOS Einstieg und Ausblick - Mobile DevCon 2011 - OPITZ CONSULTING -Stefan Sch...
 
Catarsis
CatarsisCatarsis
Catarsis
 

Ähnlich wie Test-driven JavaScript Development - OPITZ CONSULTING - Tobias Bosch - Stefan Scheidt

JavaScript Unit Testing with Jasmine
JavaScript Unit Testing with JasmineJavaScript Unit Testing with Jasmine
JavaScript Unit Testing with JasmineRaimonds Simanovskis
 
JSConf: All You Can Leet
JSConf: All You Can LeetJSConf: All You Can Leet
JSConf: All You Can Leetjohndaviddalton
 
JavaScript Functions
JavaScript FunctionsJavaScript Functions
JavaScript FunctionsBrian Moschel
 
Unit testing en iOS @ MobileCon Galicia
Unit testing en iOS @ MobileCon GaliciaUnit testing en iOS @ MobileCon Galicia
Unit testing en iOS @ MobileCon GaliciaRobot Media
 
Javascript And J Query
Javascript And J QueryJavascript And J Query
Javascript And J Queryitsarsalan
 
Introduction to Protractor
Introduction to ProtractorIntroduction to Protractor
Introduction to ProtractorJie-Wei Wu
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing UpDavid Padbury
 
JavaScript Sprachraum
JavaScript SprachraumJavaScript Sprachraum
JavaScript Sprachraumpatricklee
 
Angular promises and http
Angular promises and httpAngular promises and http
Angular promises and httpAlexe Bogdan
 
Workshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingWorkshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingVisual Engineering
 
AngularJS Testing
AngularJS TestingAngularJS Testing
AngularJS TestingEyal Vardi
 
EcmaScript 6 - The future is here
EcmaScript 6 - The future is hereEcmaScript 6 - The future is here
EcmaScript 6 - The future is hereSebastiano Armeli
 
Object-Oriented JavaScript
Object-Oriented JavaScriptObject-Oriented JavaScript
Object-Oriented JavaScriptkvangork
 
Object-Oriented Javascript
Object-Oriented JavascriptObject-Oriented Javascript
Object-Oriented Javascriptkvangork
 
Java final project of scientific calcultor
Java final project of scientific calcultorJava final project of scientific calcultor
Java final project of scientific calcultorMd. Eunus Ali Rupom
 
Secrets of JavaScript Libraries
Secrets of JavaScript LibrariesSecrets of JavaScript Libraries
Secrets of JavaScript Librariesjeresig
 

Ähnlich wie Test-driven JavaScript Development - OPITZ CONSULTING - Tobias Bosch - Stefan Scheidt (20)

JavaScript Unit Testing with Jasmine
JavaScript Unit Testing with JasmineJavaScript Unit Testing with Jasmine
JavaScript Unit Testing with Jasmine
 
JSConf: All You Can Leet
JSConf: All You Can LeetJSConf: All You Can Leet
JSConf: All You Can Leet
 
JavaScript Functions
JavaScript FunctionsJavaScript Functions
JavaScript Functions
 
Unit testing en iOS @ MobileCon Galicia
Unit testing en iOS @ MobileCon GaliciaUnit testing en iOS @ MobileCon Galicia
Unit testing en iOS @ MobileCon Galicia
 
Javascript And J Query
Javascript And J QueryJavascript And J Query
Javascript And J Query
 
Nevermore Unit Testing
Nevermore Unit TestingNevermore Unit Testing
Nevermore Unit Testing
 
Introduction to Protractor
Introduction to ProtractorIntroduction to Protractor
Introduction to Protractor
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
ES6 Let
ES6 LetES6 Let
ES6 Let
 
Introduccion a Jasmin
Introduccion a JasminIntroduccion a Jasmin
Introduccion a Jasmin
 
JS everywhere 2011
JS everywhere 2011JS everywhere 2011
JS everywhere 2011
 
JavaScript Sprachraum
JavaScript SprachraumJavaScript Sprachraum
JavaScript Sprachraum
 
Angular promises and http
Angular promises and httpAngular promises and http
Angular promises and http
 
Workshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingWorkshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testing
 
AngularJS Testing
AngularJS TestingAngularJS Testing
AngularJS Testing
 
EcmaScript 6 - The future is here
EcmaScript 6 - The future is hereEcmaScript 6 - The future is here
EcmaScript 6 - The future is here
 
Object-Oriented JavaScript
Object-Oriented JavaScriptObject-Oriented JavaScript
Object-Oriented JavaScript
 
Object-Oriented Javascript
Object-Oriented JavascriptObject-Oriented Javascript
Object-Oriented Javascript
 
Java final project of scientific calcultor
Java final project of scientific calcultorJava final project of scientific calcultor
Java final project of scientific calcultor
 
Secrets of JavaScript Libraries
Secrets of JavaScript LibrariesSecrets of JavaScript Libraries
Secrets of JavaScript Libraries
 

Mehr von OPITZ CONSULTING Deutschland

Architecture Room Stuttgart - "Cloud-native ist nur ein Teil des Spiels!"
Architecture Room Stuttgart - "Cloud-native ist nur ein Teil des Spiels!"Architecture Room Stuttgart - "Cloud-native ist nur ein Teil des Spiels!"
Architecture Room Stuttgart - "Cloud-native ist nur ein Teil des Spiels!"OPITZ CONSULTING Deutschland
 
OC|Webcast: Oracle Lizenzierung - Die größten Fallen in der Praxis
OC|Webcast: Oracle Lizenzierung - Die größten Fallen in der PraxisOC|Webcast: Oracle Lizenzierung - Die größten Fallen in der Praxis
OC|Webcast: Oracle Lizenzierung - Die größten Fallen in der PraxisOPITZ CONSULTING Deutschland
 
OC|Webcast: Oracle Lizenzierung - Virtualisierung und Cloud
OC|Webcast: Oracle Lizenzierung - Virtualisierung und CloudOC|Webcast: Oracle Lizenzierung - Virtualisierung und Cloud
OC|Webcast: Oracle Lizenzierung - Virtualisierung und CloudOPITZ CONSULTING Deutschland
 
OC|Weekly Talk: Inspect’n’Adapt – Make Change come true!
OC|Weekly Talk: Inspect’n’Adapt – Make Change come true!OC|Weekly Talk: Inspect’n’Adapt – Make Change come true!
OC|Weekly Talk: Inspect’n’Adapt – Make Change come true!OPITZ CONSULTING Deutschland
 
OC|Webcast: Schnell und clever in die AWS Cloud – Migrationsszenarien und Han...
OC|Webcast: Schnell und clever in die AWS Cloud – Migrationsszenarien und Han...OC|Webcast: Schnell und clever in die AWS Cloud – Migrationsszenarien und Han...
OC|Webcast: Schnell und clever in die AWS Cloud – Migrationsszenarien und Han...OPITZ CONSULTING Deutschland
 
OC|Weekly Talk: "Das müsste man mal digitalisieren" - Mit Low-Code schnell zu...
OC|Weekly Talk: "Das müsste man mal digitalisieren" - Mit Low-Code schnell zu...OC|Weekly Talk: "Das müsste man mal digitalisieren" - Mit Low-Code schnell zu...
OC|Weekly Talk: "Das müsste man mal digitalisieren" - Mit Low-Code schnell zu...OPITZ CONSULTING Deutschland
 
OC|Weekly Talk: Service Management – Was hat sich durch Corona geändert?
OC|Weekly Talk: Service Management – Was hat sich durch Corona geändert?OC|Weekly Talk: Service Management – Was hat sich durch Corona geändert?
OC|Weekly Talk: Service Management – Was hat sich durch Corona geändert?OPITZ CONSULTING Deutschland
 
OC|Weekly Talk - Digitales Coaching & Smart Sparring
OC|Weekly Talk - Digitales Coaching & Smart Sparring OC|Weekly Talk - Digitales Coaching & Smart Sparring
OC|Weekly Talk - Digitales Coaching & Smart Sparring OPITZ CONSULTING Deutschland
 
Effiziente Betriebsoptimierung durch Cloud Nutzung
Effiziente Betriebsoptimierung durch Cloud NutzungEffiziente Betriebsoptimierung durch Cloud Nutzung
Effiziente Betriebsoptimierung durch Cloud NutzungOPITZ CONSULTING Deutschland
 

Mehr von OPITZ CONSULTING Deutschland (20)

OC|Webcast: Grundlagen der Oracle Lizenzierung
OC|Webcast: Grundlagen der Oracle LizenzierungOC|Webcast: Grundlagen der Oracle Lizenzierung
OC|Webcast: Grundlagen der Oracle Lizenzierung
 
OC|Webcast "Java heute" vom 28.09.2021
OC|Webcast "Java heute" vom 28.09.2021OC|Webcast "Java heute" vom 28.09.2021
OC|Webcast "Java heute" vom 28.09.2021
 
OC|Webcast "Java heute" vom 24.08.2021
OC|Webcast "Java heute" vom 24.08.2021OC|Webcast "Java heute" vom 24.08.2021
OC|Webcast "Java heute" vom 24.08.2021
 
OC|Webcast "Daten wirklich nutzen"
OC|Webcast "Daten wirklich nutzen"OC|Webcast "Daten wirklich nutzen"
OC|Webcast "Daten wirklich nutzen"
 
Architecture Room Stuttgart - "Cloud-native ist nur ein Teil des Spiels!"
Architecture Room Stuttgart - "Cloud-native ist nur ein Teil des Spiels!"Architecture Room Stuttgart - "Cloud-native ist nur ein Teil des Spiels!"
Architecture Room Stuttgart - "Cloud-native ist nur ein Teil des Spiels!"
 
OC|Webcast "Willkommen in der Cloud!"
OC|Webcast "Willkommen in der Cloud!"OC|Webcast "Willkommen in der Cloud!"
OC|Webcast "Willkommen in der Cloud!"
 
OC|Webcast "Die neue Welt der Virtualisierung"
OC|Webcast "Die neue Welt der Virtualisierung"OC|Webcast "Die neue Welt der Virtualisierung"
OC|Webcast "Die neue Welt der Virtualisierung"
 
10 Thesen zur professionellen Softwareentwicklung
10 Thesen zur professionellen Softwareentwicklung10 Thesen zur professionellen Softwareentwicklung
10 Thesen zur professionellen Softwareentwicklung
 
OC|Webcast: Oracle Lizenzierung - Lizenznews 2021
OC|Webcast: Oracle Lizenzierung - Lizenznews 2021OC|Webcast: Oracle Lizenzierung - Lizenznews 2021
OC|Webcast: Oracle Lizenzierung - Lizenznews 2021
 
OC|Webcast: Oracle Lizenzierung - Die größten Fallen in der Praxis
OC|Webcast: Oracle Lizenzierung - Die größten Fallen in der PraxisOC|Webcast: Oracle Lizenzierung - Die größten Fallen in der Praxis
OC|Webcast: Oracle Lizenzierung - Die größten Fallen in der Praxis
 
OC|Webcast: Oracle Lizenzierung - Virtualisierung und Cloud
OC|Webcast: Oracle Lizenzierung - Virtualisierung und CloudOC|Webcast: Oracle Lizenzierung - Virtualisierung und Cloud
OC|Webcast: Oracle Lizenzierung - Virtualisierung und Cloud
 
OC|Webcast: Grundlagen der Oracle-Lizenzierung
OC|Webcast: Grundlagen der Oracle-LizenzierungOC|Webcast: Grundlagen der Oracle-Lizenzierung
OC|Webcast: Grundlagen der Oracle-Lizenzierung
 
OC|Weekly Talk: Inspect’n’Adapt – Make Change come true!
OC|Weekly Talk: Inspect’n’Adapt – Make Change come true!OC|Weekly Talk: Inspect’n’Adapt – Make Change come true!
OC|Weekly Talk: Inspect’n’Adapt – Make Change come true!
 
OC|Webcast: Schnell und clever in die AWS Cloud – Migrationsszenarien und Han...
OC|Webcast: Schnell und clever in die AWS Cloud – Migrationsszenarien und Han...OC|Webcast: Schnell und clever in die AWS Cloud – Migrationsszenarien und Han...
OC|Webcast: Schnell und clever in die AWS Cloud – Migrationsszenarien und Han...
 
OC|Weekly Talk The Power of DevOps…
OC|Weekly Talk  The Power of DevOps…OC|Weekly Talk  The Power of DevOps…
OC|Weekly Talk The Power of DevOps…
 
OC|Weekly Talk: "Das müsste man mal digitalisieren" - Mit Low-Code schnell zu...
OC|Weekly Talk: "Das müsste man mal digitalisieren" - Mit Low-Code schnell zu...OC|Weekly Talk: "Das müsste man mal digitalisieren" - Mit Low-Code schnell zu...
OC|Weekly Talk: "Das müsste man mal digitalisieren" - Mit Low-Code schnell zu...
 
OC|Weekly Talk: Service Management – Was hat sich durch Corona geändert?
OC|Weekly Talk: Service Management – Was hat sich durch Corona geändert?OC|Weekly Talk: Service Management – Was hat sich durch Corona geändert?
OC|Weekly Talk: Service Management – Was hat sich durch Corona geändert?
 
OC|Weekly Talk - Digitales Coaching & Smart Sparring
OC|Weekly Talk - Digitales Coaching & Smart Sparring OC|Weekly Talk - Digitales Coaching & Smart Sparring
OC|Weekly Talk - Digitales Coaching & Smart Sparring
 
OC|Weekly Talk - Beratung remote
OC|Weekly Talk - Beratung remoteOC|Weekly Talk - Beratung remote
OC|Weekly Talk - Beratung remote
 
Effiziente Betriebsoptimierung durch Cloud Nutzung
Effiziente Betriebsoptimierung durch Cloud NutzungEffiziente Betriebsoptimierung durch Cloud Nutzung
Effiziente Betriebsoptimierung durch Cloud Nutzung
 

Kürzlich hochgeladen

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 

Kürzlich hochgeladen (20)

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Test-driven JavaScript Development - OPITZ CONSULTING - Tobias Bosch - Stefan Scheidt

  • 1. Tobias Bosch & Stefan Scheidt/ OPITZ CONSULTING GmbH Test-Driven JavaScript Development
  • 2. Wer sind wir? tobias.bosch@opitz-consulting.com (@tigbro) stefan.scheidt@opitz-consulting.com (@beezlebug)
  • 3.
  • 5. In diesem Vortrag geht‘s um... ...automatisiertes Testen ...durch Entwickler
  • 9. In diesem Vortrag: Icon Set by Paul Irish (http://paulirish.com/2010/high-res-browser-icons/)
  • 11. „Klassisch“ mit xUnit-Asserts „BDD-Style“ à la RSpec
  • 12. Demo: BDD mit Jasmine
  • 13. describe("parseFloat", function() { it("shouldreturnundefinedforundefined", function () { expect(util.parseFloat(undefined)).toBeUndefined(); }); it("shouldreturn 0 foremptystring", function () { expect(util.parseFloat('')).toEqual(0); }); it("shouldreturnnumberfornumberstrings", function () { expect(util.parseFloat('1.5')).toEqual(1.5); }); // ... }); Hello Jasmine!
  • 14. describe("parseFloat", function() { it("shouldreturnundefinedforundefined", function () { expect(util.parseFloat(undefined)).toBeUndefined(); }); it("shouldreturn 0 foremptystring", function () { expect(util.parseFloat('')).toEqual(0); }); it("shouldreturnnumberfornumberstrings", function () { expect(util.parseFloat('1.5')).toEqual(1.5); }); // ... }); Hello Jasmine! Suite
  • 15. describe("parseFloat", function() { it("shouldreturnundefinedforundefined", function () { expect(util.parseFloat(undefined)).toBeUndefined(); }); it("shouldreturn 0 foremptystring", function () { expect(util.parseFloat('')).toEqual(0); }); it("shouldreturnnumberfornumberstrings", function () { expect(util.parseFloat('1.5')).toEqual(1.5); }); // ... }); Hello Jasmine! Specs
  • 16. describe("parseFloat", function() { it("shouldreturnundefinedforundefined", function () { expect(util.parseFloat(undefined)).toBeUndefined(); }); it("shouldreturn 0 foremptystring", function () { expect(util.parseFloat('')).toEqual(0); }); it("shouldreturnnumberfornumberstrings", function () { expect(util.parseFloat('1.5')).toEqual(1.5); }); // ... }); Hello Jasmine! Matcher
  • 17. Hello Jasmine! expect(x).toEqual(y); expect(x).toBe(y); expect(x).toBeDefined(); expect(x).toBeUndefined(); expect(x).toBeTruthy(); expect(x).toBeFalsy(); ... Matcher
  • 20. Spies
  • 21. Spies describe("execute fadein", function() { it("should eventually set opacity to 1", function () { varelement = document.createElement("div"); spyOn(window, 'setTimeout').andCallFake( function(callback) { callback(); }); spyOn(util, 'opacity'); fadein.execute(element); expect(util.opacity.mostRecentCall.args[1]).toEqual(1); }); });
  • 22. Spies describe("execute fadein", function() { it("should eventually set opacity to 1", function () { varelement = document.createElement("div"); spyOn(window, 'setTimeout').andCallFake( function(callback) { callback(); }); spyOn(util, 'opacity'); fadein.execute(element); expect(util.opacity.mostRecentCall.args[1]).toEqual(1); }); });
  • 23. Spies describe("execute fadein", function() { it("should eventually set opacity to 1", function () { varelement = document.createElement("div"); spyOn(window, 'setTimeout').andCallFake( function(callback) { callback(); }); spyOn(util, 'opacity'); fadein.execute(element); expect(util.opacity.mostRecentCall.args[1]).toEqual(1); }); }); Arrange
  • 24. Spies describe("execute fadein", function() { it("should eventually set opacity to 1", function () { varelement = document.createElement("div"); spyOn(window, 'setTimeout').andCallFake( function(callback) { callback(); }); spyOn(util, 'opacity'); fadein.execute(element); expect(util.opacity.mostRecentCall.args[1]).toEqual(1); }); }); Arrange // waitsfor 'delay' seconds // thencallscallback window.setTimeout = function (callback, delay) { ... };
  • 25. Spies describe("execute fadein", function() { it("should eventually set opacity to 1", function () { varelement = document.createElement("div"); spyOn(window, 'setTimeout').andCallFake( function(callback) { callback(); }); spyOn(util, 'opacity'); fadein.execute(element); expect(util.opacity.mostRecentCall.args[1]).toEqual(1); }); }); Arrange // setopacityof 'element' to 'opacity' util.opacity = function (element, opacity) { ... };
  • 26. Spies describe("execute fadein", function() { it("should eventually set opacity to 1", function () { varelement = document.createElement("div"); spyOn(window, 'setTimeout').andCallFake( function(callback) { callback(); }); spyOn(util, 'opacity'); fadein.execute(element); expect(util.opacity.mostRecentCall.args[1]).toEqual(1); }); }); Act
  • 27. Spies describe("execute fadein", function() { it("should eventually set opacity to 1", function () { varelement = document.createElement("div"); spyOn(window, 'setTimeout').andCallFake( function(callback) { callback(); }); spyOn(util, 'opacity'); fadein.execute(element); expect(util.opacity.mostRecentCall.args[1]).toEqual(1); }); }); // setopacityof 'element' to 'opacity' util.opacity = function (element, opacity) { ... }; Assert
  • 29. Matcher für Spies Eigenschaften von Spies
  • 31. it("should eventually set opacity to 1", function() { var element = document.createElement("div"); spyOn(util, 'opacity'); runs(function() { fadein.execute(element); }); waitsFor(function () { return opacitySpy.mostRecentCall.args[1] === 1; }); runs(function() { // some other expectations expect(opacitySpy.mostRecentCall.args[1]).toEqual(1); }); }); Asynchrone Tests
  • 32. it("should eventually set opacity to 1", function() { var element = document.createElement("div"); spyOn(util, 'opacity'); runs(function() { fadein.execute(element); }); waitsFor(function () { return opacitySpy.mostRecentCall.args[1] === 1; }); runs(function() { // some other expectations expect(opacitySpy.mostRecentCall.args[1]).toEqual(1); }); }); Asynchrone Tests Arrange
  • 33. it("should eventually set opacity to 1", function() { var element = document.createElement("div"); spyOn(util, 'opacity'); runs(function() { fadein.execute(element); }); waitsFor(function () { return opacitySpy.mostRecentCall.args[1] === 1; }); runs(function() { // some other expectations expect(opacitySpy.mostRecentCall.args[1]).toEqual(1); }); }); Asynchrone Tests Act
  • 34. it("should eventually set opacity to 1", function() { var element = document.createElement("div"); spyOn(util, 'opacity'); runs(function() { fadein.execute(element); }); waitsFor(function () { return opacitySpy.mostRecentCall.args[1] === 1; }); runs(function() { // some other expectations expect(opacitySpy.mostRecentCall.args[1]).toEqual(1); }); }); Asynchrone Tests Wait... // setopacityof 'element' to 'opacity' util.opacity = function (element, opacity) { ... };
  • 35. it("should eventually set opacity to 1", function() { var element = document.createElement("div"); spyOn(util, 'opacity'); runs(function() { fadein.execute(element); }); waitsFor(function () { return opacitySpy.mostRecentCall.args[1] === 1; }); runs(function() { // some other expectations expect(opacitySpy.mostRecentCall.args[1]).toEqual(1); }); }); Asynchrone Tests Assert
  • 37.
  • 38. it("should fade in hello div on buttonclick", function () { varwin, field, button; loadHtml("/js-fadein/index.html"); runs(function() { win = testwindow(); field = win.document.getElementById('hello'); button = win.document.getElementById('fadein'); }); runs(function () { expect(win.util.opacity(field)).toEqual(0); jasmine.ui.simulate(button, 'click'); }); waitsForAsync(); runs(function () { expect(win.util.opacity(field)).toEqual(1); }); }); UI-Test mit Jasmine-UI
  • 39. it("should fade in hello div on buttonclick", function () { varwin, field, button; loadHtml("/js-fadein/index.html"); runs(function() { win = testwindow(); field = win.document.getElementById('hello'); button = win.document.getElementById('fadein'); }); runs(function () { expect(win.util.opacity(field)).toEqual(0); jasmine.ui.simulate(button, 'click'); }); waitsForAsync(); runs(function () { expect(win.util.opacity(field)).toEqual(1); }); }); The indexpage... UI-Test mit Jasmine-UI
  • 40. it("should fade in hello div on buttonclick", function () { varwin, field, button; loadHtml("/js-fadein/index.html"); runs(function() { win = testwindow(); field = win.document.getElementById('hello'); button = win.document.getElementById('fadein'); }); runs(function () { expect(win.util.opacity(field)).toEqual(0); jasmine.ui.simulate(button, 'click'); }); waitsForAsync(); runs(function () { expect(win.util.opacity(field)).toEqual(1); }); }); Arrange, Part 1 UI-Test mit Jasmine-UI
  • 41. it("should fade in hello div on buttonclick", function () { varwin, field, button; loadHtml("/js-fadein/index.html"); runs(function() { win = testwindow(); field = win.document.getElementById('hello'); button = win.document.getElementById('fadein'); }); runs(function () { expect(win.util.opacity(field)).toEqual(0); jasmine.ui.simulate(button, 'click'); }); waitsForAsync(); runs(function () { expect(win.util.opacity(field)).toEqual(1); }); }); Arrange, Part 2 UI-Test mit Jasmine-UI
  • 42. it("should fade in hello div on buttonclick", function () { varwin, field, button; loadHtml("/js-fadein/index.html"); runs(function() { win = testwindow(); field = win.document.getElementById('hello'); button = win.document.getElementById('fadein'); }); runs(function () { expect(win.util.opacity(field)).toEqual(0); jasmine.ui.simulate(button, 'click'); }); waitsForAsync(); runs(function () { expect(win.util.opacity(field)).toEqual(1); }); }); Act UI-Test mit Jasmine-UI
  • 43. it("should fade in hello div on buttonclick", function () { varwin, field, button; loadHtml("/js-fadein/index.html"); runs(function() { win = testwindow(); field = win.document.getElementById('hello'); button = win.document.getElementById('fadein'); }); runs(function () { expect(win.util.opacity(field)).toEqual(0); jasmine.ui.simulate(button, 'click'); }); waitsForAsync(); runs(function () { expect(win.util.opacity(field)).toEqual(1); }); }); Wait... UI-Test mit Jasmine-UI
  • 44. it("should fade in hello div on buttonclick", function () { varwin, field, button; loadHtml("/js-fadein/index.html"); runs(function() { win = testwindow(); field = win.document.getElementById('hello'); button = win.document.getElementById('fadein'); }); runs(function () { expect(win.util.opacity(field)).toEqual(0); jasmine.ui.simulate(button, 'click'); }); waitsForAsync(); runs(function () { expect(win.util.opacity(field)).toEqual(1); }); }); Assert UI-Test mit Jasmine-UI
  • 46.
  • 50. Fazit Es gibt ein umfangreiches Toolset zum Testen von JavaScript-Code. Testen Sie Ihren Code! Testen Sie insbesondere Ihren JavaScript-Code! Sie haben keine Ausrede...
  • 51. Links
  • 52. saturatedwriting (ByEduordo, http://www.flickr.com/photos/tnarik/366393127/) Smiley Keyboard (By~Prescott, http://www.flickr.com/photos/ppym1/93571524/) Spyhole, Paris (Bysmithofsmiths, http://www.flickr.com/photos/hesketh/232015302/) Sortasynchroniseddiving (By Aaron Retz, http://www.flickr.com/photos/aretz/309469339/)
  • 53. StampCollector (ByC. Castillo, http://www.flickr.com/photos/carolinedecastillo/2750577684/) bios[bible] (ByGastev, http://www.flickr.com/photos/gastev/2174505811/) Day 276/365: in hotpursuit (By Tina Vega, http://www.flickr.com/photos/tinavega/3066602429/)
  • 54. Vielen Dankfür Ihr Interesse!@tigbro@beezlebug