Upgrade to Pro — share decks privately, control downloads, hide ads and more …

BDD wat?

BDD wat?

introducing BDD for the YUI crowd

Simon Højberg

November 15, 2012
Tweet

More Decks by Simon Højberg

Other Decks in Programming

Transcript

  1. ALWAYS START BY Describing behavior Get a red test THEN

    Build the behavior Get a green test Wednesday, November 14, 12
  2. describe(‘MilliniumFalcon.HyperDrive’, function () { beforeEach(function () { /* .. */

    }); it(‘works when punched’, function (expect) { /* .. */ }); it(‘can reach FTL speed’, function (expect) { /* .. */ }); }); Wednesday, November 14, 12
  3. describe(‘MilliniumFalcon.HyperDrive’, function () { beforeEach(function () { /* .. */

    }); it(‘works when punched’, function (expect) { /* .. */ }); it(‘can reach FTL speed’, function (expect) { /* .. */ }); }); Wednesday, November 14, 12
  4. describe(‘MilliniumFalcon.HyperDrive’, function () { var subject; beforeEach(function () { subject

    = new Y.MilliniumFalcon.HyperDrive(); }); it(‘works when punched’, function (expect) { /* .. */ }); it(‘can reach FTL speed’, function (expect) { /* .. */ }); }); Wednesday, November 14, 12
  5. describe(‘MilliniumFalcon.HyperDrive’, function () { var subject; beforeEach(function () { subject

    = new Y.MilliniumFalcon.HyperDrive(); }); it(‘works when punched’, function (expect) { /* .. */ }); it(‘can reach FTL speed’, function (expect) { /* .. */ }); }); Wednesday, November 14, 12
  6. describe(‘MilliniumFalcon.HyperDrive’, function () { var subject; beforeEach(function () { subject

    = new Y.MilliniumFalcon.HyperDrive(); }); it(‘works when punched’, function (expect) { subject.punch(); expect( subject.get(‘isOperational’) ).toBe( true ); }); it(‘can reach FTL speed’, function (expect) { /* .. */ }); }); Wednesday, November 14, 12
  7. describe(‘MilliniumFalcon.HyperDrive’, function () { var subject; beforeEach(function () { subject

    = new Y.MilliniumFalcon.HyperDrive(); }); it(‘works when punched’, function (expect) { subject.punch(); expect( subject.get(‘isOperational’) ).toBe( true ); }); it(‘can reach FTL speed’, function (expect) { /* .. */ }); }); Wednesday, November 14, 12
  8. describe(‘MilliniumFalcon.HyperDrive’, function () { var subject; beforeEach(function () { subject

    = new Y.MilliniumFalcon.HyperDrive(); }); it(‘works when punched’, function (expect) { subject.punch(); expect( subject.get(‘isOperational’) ).toBe( true ); }); it(‘can reach FTL speed’, function (expect) { subject.jump(); expect( subject.get(‘speed’) ).toBe( ‘FTL’ ); }); }); Wednesday, November 14, 12
  9. describe(‘MilliniumFalcon.HyperDrive’, function () { var subject; beforeEach(function () { subject

    = new Y.MilliniumFalcon.HyperDrive(); }); it(‘works when punched’, function (expect) { subject.punch(); expect( subject.get(‘isOperational’) ).toBe( true ); }); it(‘can reach FTL speed’, function (expect) { subject.jump(); expect( subject.get(‘speed’) ).toBe( ‘FTL’ ); }); }); Wednesday, November 14, 12
  10. ALWAYS START BY Describing behavior Get a red test THEN

    Build the behavior Get a green test Wednesday, November 14, 12
  11. /** @author Simon Højberg @company swipely.com @twitter @shojberg @github github.com/hojberg/primrose

    **/ var thanks = function () { Y.log(“YOU’RE AWESOME!”); }; Wednesday, November 14, 12