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

How Important is Testing

How Important is Testing

Writing tests first can seem overwhelming - But testing actually can make writing code easier!

Avatar for Sana Nasar

Sana Nasar

June 27, 2015
Tweet

More Decks by Sana Nasar

Other Decks in Technology

Transcript

  1. Understanding BDD and TDD • Test Driven Development in simple

    form is : Write your tests. Watch them fail. Make them pass. Refactor. Repeat.
  2. 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
  3. 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.
  4. 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.
  5. • “One test is worth a thousand expert opinions”. Imagine

    you writing the test and saying with confidence (that damn thing works!)
  6. • 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.
  7. • 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.
  8. 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/