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

Getting Started with Unit Testing

Getting Started with Unit Testing

Lalit Vijay

June 03, 2017
Tweet

More Decks by Lalit Vijay

Other Decks in Programming

Transcript

  1. WHAT IS UNIT TESTING? Unit testing is a software development

    process in which the smallest testable parts of an application, called units, are individually and independently scrutinized for proper operation. Unit testing can be done manually but is often automated. BASICS
  2. 01 Test-driven development (TDD) is a software development process that

    relies on the repetition of a very short development cycle: requirements are turned into very specific test cases, then the software is improved to pass the new tests, only. BASICS WHAT’S TDD?
  3. WHERE TO START 1. Start easy 2. Solve your current

    pain 3. Its easy to write bad unit tests
  4. WHAT TO TEST FIRST? If you feel a need of

    dd or var_dump, you can unit test for that You always now what's the output right? Output is the first test
  5. TOOLS FOR TESTING? DIEGO MARTIN Use Framework, No need to

    reinvent the wheel. For most of the languages, we have unit testing frameworks, Unit testing is not about the language it's about improving your codebase and architecture. For today its PHPUnit
  6. 02 You need the ability to look at all the

    different aspects of a problem. GREATLY HANDS-ON GO BEYOND The more you are able to loop through, the higher chance you have for good results. ALWAYS ITERATIVE LOOP THROUGH
  7. 03 PITFALLS TO AVOID Unit testing is not about finding

    bugs Testing Obsession Don't Test too many things in One Test Case Don’t make unnecessary assertions Not Mocking external services and state
  8. Some Good habbit Make each test independent to others Name

    your unit tests clearly Don’t unit test configuration settings Practice makes a man perfect