Slide 1

Slide 1 text

How Important is Testing. How Testing makes writing code even more easier!

Slide 2

Slide 2 text

Understanding BDD and TDD • Test Driven Development in simple form is : Write your tests. Watch them fail. Make them pass. Refactor. Repeat.

Slide 3

Slide 3 text

BDD – Behavior Driven Development • BDD – Behavior Driven Development on the other hand is a little more complex. It is more of a team work. • It is more of how a desired behavior should be specified. • In this concept, Business Analysts and Developers should specify behaviors in terms of “User Stories”. • Involving the stake holders in the implementation process through outside-in Software Development. • Now we have our own “Jasmine” which helps us test our JavaScript code in a more TDD way of style. • For more information on BDD learn here (Wiki is the best!)http://en.wikipedia.org/wiki/Behavior- driven_development

Slide 4

Slide 4 text

Real Code! Wohoo…. • If you're all into Rspec, you’ll see Jasmine Framework very similar. describe('JavaScript addition operator', function () { it('adds two numbers together', function () { expect(1 + 2).toEqual(3); }); }); • “Describe” and “it” functions – Take two parameters a string and a function. • Inside “it” block – Write setup code you need for your test. • Ready to write the actual test – Start with the “expect” function.

Slide 5

Slide 5 text

Setting up Jasmine

Slide 6

Slide 6 text

So why the Test?? • Unit tests and test-driven development (TDD) have so many hidden and personal benefits as well as the obvious ones, you just can't really explain to somebody until they're doing it themselves. • Unit tests allows you to make big changes to code quickly. • You know it works now for sure (because you’ve run the tests!) • When you follow TDD no code is considered as bad/buggy/annoying. • Unit test helps you to understand the design of the code that you’re working on.

Slide 7

Slide 7 text

• “One test is worth a thousand expert opinions”. Imagine you writing the test and saying with confidence (that damn thing works!)

Slide 8

Slide 8 text

• Good unit tests can help document and define what something is supposed to do • Unit tests help with code re-use. Migrate both your code and your tests to your new project. Tweak the code till the tests run again. • Writing unit tests can consume a lot of time in the beginning but it’s so much worth it. Sold! You know it’s good for you, then why not start testing your code.

Slide 9

Slide 9 text

• Good unit tests can help document and define what something is supposed to do • Unit tests help with code re-use. Migrate both your code and your tests to your new project. Tweak the code till the tests run again. • Writing unit tests can consume a lot of time in the beginning but it’s so much worth it. Sold! You know it’s good for you, then why not start testing your code.

Slide 10

Slide 10 text

Resources! • BDD Wiki • TDD Wiki • https://github.com/jasmine/jasmine/wiki • Rspec Rails • http://agiledata.org/essays/tdd.html • http://c2.com/cgi/wiki?TestDrivenDevelopment Books: • http://www.amazon.com/Test-Driven-Development-By- Example/dp/0321146530 • http://www.amazon.com/dp/0596006896/?tag=stackoverfl08 -20 • http://www.growing-object-oriented-software.com/

Slide 11

Slide 11 text

Have fun testing!  Follow me on Twitter: @SanaNasar_