Unit Testing
         Test early and test often.



by   AbdAllah SaeeD
Yet Another CAT Stand-up session

               :)
Software Development Life Cycle




Keywords: SDLC, Software Testing
Software Tester
   
       Who is he?

   
       Software Testing:
         
             A part of build automation.
...
Unit Test?

    Test Cases?


    Unit Testing is a method in which a
    programmer tests if individual units of source...
Why?

    Find problems early in the development cycle.


    A way to Optimality.


    Can be used to validate that t...
When?

    How do you know that a method needs a unit
    test?

    
        Is the code too simple?
    
        Can ...
Danger!
   
       you don't have to define unit tests for every
       single method you have.
   Although this leads to...
Automated Testing

                       Input


  Main class                   Testing Class
                           ...
Automated Testing

•   There are two ways to test your code
     –   The standard way:
           •   Create a class that ...
The standard way
•   What's wrong with this method?
     –   Too hard to implement in Huge applications.

     –   The tes...
Unit Testing Frameworks

  •   Unit testing frameworks help simplify the
      process of unit testing.


  •   You can wr...
Unit Testing Frameworks

  •    Examples:
        –   JUnit (Java)
        –   NUnit (.NET)
        –   Doctest (Python)

...
JUnit

•   A simple, open source
    framework to write and run
    repeatable tests.


•   Homepage: http://junit.org


•...
Getting our hands dirty

•   Java
     –   JUnit
     –   Under Eclipse IDE


•   Python
     –   Doctest
     –   Under a...
Keywords

•   SDLC.                  •   Java
•   Software Testing.      •   Eclipse
•   Test Case              •   JUnit
...
Resources

•   http://en.wikipedia.org
•   http://bashmohandes.blogspot.com
•   http://www.softwaretestinghelp.com/
•   ht...
Questions?
Thanks!
Upcoming SlideShare
Loading in...5
×

Unit testing presentation

4,387

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
4,387
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
168
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Unit testing presentation

  1. 1. Unit Testing Test early and test often. by AbdAllah SaeeD
  2. 2. Yet Another CAT Stand-up session :)
  3. 3. Software Development Life Cycle Keywords: SDLC, Software Testing
  4. 4. Software Tester  Who is he?  Software Testing:  A part of build automation.  Manual.  More about testing and testers:  http://www.softwaretestinghelp.com/ Keywords: Software Tester, Unit Testing
  5. 5. Unit Test?  Test Cases?  Unit Testing is a method in which a programmer tests if individual units of source code are fit for use.  Unit Testing is the first level of Software Testing.
  6. 6. Why?  Find problems early in the development cycle.  A way to Optimality.  Can be used to validate that the code functionality still works after code changes.  Documentation.
  7. 7. When?  How do you know that a method needs a unit test?  Is the code too simple?  Can it be tested by inspection?  Any method that can break is a good candidate for having a unit test.
  8. 8. Danger!  you don't have to define unit tests for every single method you have. Although this leads to:  Incomplete coverage. But:  The careful programmer will know that their unit tests must cover every cluster of objects that form their application. Keywords: Integration Testing
  9. 9. Automated Testing Input Main class Testing Class Contains the Testing Contains the actual code that will code that need to be operate on the tested. output of the main class. Output True | False?
  10. 10. Automated Testing • There are two ways to test your code – The standard way: • Create a class that takes the input and output from the class we want to test after compiling it. Then compile this testing class. – Unit Testing: • Create a class that interacts with the classes and methods -including private ones- of the class we want to test and only compile the testing class.
  11. 11. The standard way • What's wrong with this method? – Too hard to implement in Huge applications. – The testing code is totally separated from the main code. – Compiling Twice! • Main class compilation • Test class compilation – Wasting precious time!
  12. 12. Unit Testing Frameworks • Unit testing frameworks help simplify the process of unit testing. • You can write unit tests without using any framework. – Slower. – And more error-prone. Keywords: Software Framework
  13. 13. Unit Testing Frameworks • Examples: – JUnit (Java) – NUnit (.NET) – Doctest (Python) • For the complete list of unit testing frameworks: – http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks Keywords: JUnit, NUnit, Doctest
  14. 14. JUnit • A simple, open source framework to write and run repeatable tests. • Homepage: http://junit.org • Now, lets test!
  15. 15. Getting our hands dirty • Java – JUnit – Under Eclipse IDE • Python – Doctest – Under any terminal
  16. 16. Keywords • SDLC. • Java • Software Testing. • Eclipse • Test Case • JUnit • Unit Testing. • NUnit • Integration Testing. • Python • System Testing. • Doctest
  17. 17. Resources • http://en.wikipedia.org • http://bashmohandes.blogspot.com • http://www.softwaretestinghelp.com/ • http://www.vogella.de • http://junit.sourceforge.net • http://junit.org
  18. 18. Questions?
  19. 19. Thanks!
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×