SlideShare a Scribd company logo
1 of 76
Download to read offline
TEST-DRIVEN JAVASCRIPT
                            Für mehr Qualität in JavaScript-Applikationen




Wednesday, January 23, 13
WER BIN ICH?

    • Sebastian             Springer

    • 30

    • Dipl. Inf. (FH)

    • Teamleiter             @ Mayflower München

    • Nebenbei: JavaScript-Entwickler

    • @basti_springer

Wednesday, January 23, 13
WAS ERWARTET EUCH?




                                 ?
Wednesday, January 23, 13
WAS ERWARTET EUCH?

    • Was           ist TDD?




                                 ?
Wednesday, January 23, 13
WAS ERWARTET EUCH?

    • Was           ist TDD?




                                 ?
    • Warum TDD?




Wednesday, January 23, 13
WAS ERWARTET EUCH?

    • Was           ist TDD?




                                          ?
    • Warum TDD?

    • Was           benötige ich dafür?




Wednesday, January 23, 13
WAS ERWARTET EUCH?

    • Was           ist TDD?




                                          ?
    • Warum TDD?

    • Was           benötige ich dafür?
    • Wie           funktioniert’s?




Wednesday, January 23, 13
WAS
 IST
 TDD?
    WARUM
 TDD?
    VORAUSSETZUNGEN?
    WIE
 FUNKTIONIERT’S?



Wednesday, January 23, 13
WAS IST TDD?
    • Angewandtes            Softwaredesign und -entwicklung

    • Erst Tests, dann         den Code

    • Red, Green, Refactor

    • Clean            Code that works




Wednesday, January 23, 13
TDD
 ist
 doof

Wednesday, January 23, 13
DIE SCHATTENSEITEN
  • Verständnis

  • Disziplin               und Konsequenz

  • Einstiegshürde

  • Anfänglich               langsame Geschwindigkeit




Wednesday, January 23, 13
WAS
 IST
 TDD?   ✓
    WARUM
 TDD?
    VORAUSSETZUNGEN?
    WIE
 FUNKTIONIERT’S?



Wednesday, January 23, 13
Weil’s
 geht!

Wednesday, January 23, 13
Das Problem verstehen




Wednesday, January 23, 13
Sicherheit für Refactorings




Wednesday, January 23, 13
Schnelles Feedback




Wednesday, January 23, 13
Software muss getestet werden




Wednesday, January 23, 13
Software muss getestet werden
                            entweder manuell oder automatisch




Wednesday, January 23, 13
Dokumentation




Wednesday, January 23, 13
Basis für Weiterentwicklung




Wednesday, January 23, 13
Besserer Code




Wednesday, January 23, 13
Weniger Bugs




Wednesday, January 23, 13
Spaß an der Arbeit




Wednesday, January 23, 13
Qualität und Lauffähigkeit




Wednesday, January 23, 13
WAS
 IST
 TDD?   ✓
    WARUM
 TDD?                                      ✓
    VORAUSSETZUNGEN?
    WIE
 FUNKTIONIERT’S?



Wednesday, January 23, 13
IDE




Wednesday, January 23, 13
FRAMEWORK




Wednesday, January 23, 13
BROWSER




Wednesday, January 23, 13
Gibt’s
 das
 nicht
 in
 
            besser?
Wednesday, January 23, 13
INTEGRATION




Wednesday, January 23, 13
INTEGRATION



                             JsTestDriver Plugin




Wednesday, January 23, 13
JSTESTDRIVER




Wednesday, January 23, 13
+   =   ♥

Wednesday, January 23, 13
WAS
 IST
 TDD?   ✓
    WARUM
 TDD?                                      ✓
    VORAUSSETZUNGEN?                                                                 ✓
    WIE
 FUNKTIONIERT’S?



Wednesday, January 23, 13
DAS BEISPIEL:
                             FIZZ BUZZ



Wednesday, January 23, 13
FIZZ BUZZ

    • Es       wird eine Zahl eingegeben.

    • Ist      die Zahl durch 3 teilbar, ist das Ergebnis “fizz”.

    • Ist      die Zahl durch 5 teilbar, ist das Ergebnis “buzz”.

    • Ist  die Zahl sowohl durch 3 als auch durch 5 teilbar, ist das
        Ergebnis “fizzbuzz”.


Wednesday, January 23, 13
FIZZ BUZZ
         1                  1      11   11        21   fizz
         2                  2      12   fizz       22   22
         3                  fizz    13   13        23   23
         4                  4      14   14        24   fizz
         5                  buzz   15   fizzbuzz   25   buzz
         6                  fizz    16   16        26   26
         7                  7      17   17        27   fizz
         8                  8      18   fizz       28   28
         9                  fizz    19   19        29   29
         10                 buzz   20   buzz      30   fizzbuzz


Wednesday, January 23, 13
SETUP




Wednesday, January 23, 13
FIZZBUZZ.JSTD

                             load:
                               - lib/jasmine.js
                               - lib/JasmineAdapter.js
                               - spec/FizzBuzz.spec.js
                               - src/FizzBuzz.js




    • YAML-Format

    • Speicherorte          der verschiedenen Dateien

Wednesday, January 23, 13
Wednesday, January 23, 13
Na
 dann
 mal
 los!

Wednesday, January 23, 13
TEST FIRST


    • Erst         den Test, dann den Quellcode

    • Anforderungen           in Test übersetzen

    • One            problem a time




Wednesday, January 23, 13
describe(FizzBuzz, function () {
      use strict;

              it(should return 1, if 1 is provided, function () {
                  expect(fizzbuzz(1)).toEqual(1);
              });

  });




Wednesday, January 23, 13
red


Wednesday, January 23, 13
EINFACHSTE LÖSUNG



    • Ziel: Der Test          muss grün werden.

    • Fokus            auf die aktuelle Problemstellung




Wednesday, January 23, 13
FAKE IT ‘TIL YOU MAKE IT


    • Umsetzung                mit fixen Werten

    • Tests          werden sehr schnell grün

    • Wenig                 Code

    • Kein          Over-Engineering



Wednesday, January 23, 13
var fizzbuzz = function () {
                                use strict;
                                return 1;
                            };




Wednesday, January 23, 13
green


Wednesday, January 23, 13
TRIANGULATION


    • Mehrere Tests          mit verschiedenen Werten

    • Klare           Implementierung

    • Saubere Abstraktion

    • Tests          mit Grenzwerten



Wednesday, January 23, 13
it(should return 2, if 2 is provided, function () {
             expect(fizzbuzz(2)).toEqual(2);
         });




Wednesday, January 23, 13

More Related Content

More from Sebastian Springer

Creating Enterprise Web Applications with Node.js
Creating Enterprise Web Applications with Node.jsCreating Enterprise Web Applications with Node.js
Creating Enterprise Web Applications with Node.jsSebastian Springer
 
Divide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsDivide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsSebastian Springer
 
From Zero to Hero – Web Performance
From Zero to Hero – Web PerformanceFrom Zero to Hero – Web Performance
From Zero to Hero – Web PerformanceSebastian Springer
 
Von 0 auf 100 - Performance im Web
Von 0 auf 100 - Performance im WebVon 0 auf 100 - Performance im Web
Von 0 auf 100 - Performance im WebSebastian Springer
 
ECMAScript 6 im Produktivbetrieb
ECMAScript 6 im ProduktivbetriebECMAScript 6 im Produktivbetrieb
ECMAScript 6 im ProduktivbetriebSebastian Springer
 
Große Applikationen mit AngularJS
Große Applikationen mit AngularJSGroße Applikationen mit AngularJS
Große Applikationen mit AngularJSSebastian Springer
 
Best Practices für TDD in JavaScript
Best Practices für TDD in JavaScriptBest Practices für TDD in JavaScript
Best Practices für TDD in JavaScriptSebastian Springer
 
Warum ECMAScript 6 die Welt ein Stückchen besser macht
Warum ECMAScript 6 die Welt ein Stückchen besser machtWarum ECMAScript 6 die Welt ein Stückchen besser macht
Warum ECMAScript 6 die Welt ein Stückchen besser machtSebastian Springer
 

More from Sebastian Springer (20)

Schnelleinstieg in Angular
Schnelleinstieg in AngularSchnelleinstieg in Angular
Schnelleinstieg in Angular
 
Creating Enterprise Web Applications with Node.js
Creating Enterprise Web Applications with Node.jsCreating Enterprise Web Applications with Node.js
Creating Enterprise Web Applications with Node.js
 
Divide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsDivide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.js
 
From Zero to Hero – Web Performance
From Zero to Hero – Web PerformanceFrom Zero to Hero – Web Performance
From Zero to Hero – Web Performance
 
Von 0 auf 100 - Performance im Web
Von 0 auf 100 - Performance im WebVon 0 auf 100 - Performance im Web
Von 0 auf 100 - Performance im Web
 
A/B Testing mit Node.js
A/B Testing mit Node.jsA/B Testing mit Node.js
A/B Testing mit Node.js
 
Angular2
Angular2Angular2
Angular2
 
Einführung in React
Einführung in ReactEinführung in React
Einführung in React
 
JavaScript Performance
JavaScript PerformanceJavaScript Performance
JavaScript Performance
 
ECMAScript 6 im Produktivbetrieb
ECMAScript 6 im ProduktivbetriebECMAScript 6 im Produktivbetrieb
ECMAScript 6 im Produktivbetrieb
 
Streams in Node.js
Streams in Node.jsStreams in Node.js
Streams in Node.js
 
JavaScript Performance
JavaScript PerformanceJavaScript Performance
JavaScript Performance
 
Große Applikationen mit AngularJS
Große Applikationen mit AngularJSGroße Applikationen mit AngularJS
Große Applikationen mit AngularJS
 
Testing tools
Testing toolsTesting tools
Testing tools
 
Node.js Security
Node.js SecurityNode.js Security
Node.js Security
 
Typescript
TypescriptTypescript
Typescript
 
Reactive Programming
Reactive ProgrammingReactive Programming
Reactive Programming
 
Best Practices für TDD in JavaScript
Best Practices für TDD in JavaScriptBest Practices für TDD in JavaScript
Best Practices für TDD in JavaScript
 
Warum ECMAScript 6 die Welt ein Stückchen besser macht
Warum ECMAScript 6 die Welt ein Stückchen besser machtWarum ECMAScript 6 die Welt ein Stückchen besser macht
Warum ECMAScript 6 die Welt ein Stückchen besser macht
 
Lean Startup mit JavaScript
Lean Startup mit JavaScriptLean Startup mit JavaScript
Lean Startup mit JavaScript
 

Recently uploaded

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
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
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 

Recently uploaded (20)

+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...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
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
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 

Webinar Test-Driven JavaScript