SlideShare a Scribd company logo
Unit Testing
08/11/2011
Softjourn Inc.




Unit Testing

  Anatoliy Okhotnikov
  Softjourn Inc.
Agenda
●   What is Unit Testing?
●   Benefits
●   What is Test Driven Development?
●   What is Behavior Driven Development?
●   Categories of (Unit) Tests / Software Testing
    Pyramid, Frameworks
●   C++, Java, .NET, Perl, PHP frameworks
●   Unit-testing Zend Framework application
What is Unit Testing?
●   Ford new engine test area
●   Special test harness that
    connects a gas and oil line
●   For the output, a measuring
    device is connected to the
    drive shaft that comes
    directly out of the engine
●   Engine starts and revs up
●   Within about 5 minutes the
    computer is able to analyze
    the torque curve, gas
    usage, and oil usage
What is Unit Testing?
●   In computer programming, unit testing is a method by which
    individual units of source code are tested to determine if they
    are fit for use. A unit is the smallest testable part of an
    application. In procedural programming a unit may be an
    individual function or procedure. Unit tests are created by
    programmers or occasionally by white box testers.
●   Ideally, each test case is independent from the others:
    substitutes like method stubs, mock objects, fakes and test
    harnesses can be used to assist testing a module in
    isolation. Unit tests are typically written and run by software
    developers to ensure that code meets its design and
    behaves as intended. Its implementation can vary from
    being very manual (pencil and paper) to being formalized as
    part of build automation
Benefits
    The goal of unit testing is to isolate each part of the program and
    show that the individual parts are correct. A unit test provides a
    strict, written contract that the piece of code must satisfy. As a
    result, it affords several benefits.
●   Find problems early (in the development cycle)
●   Facilitates change (refactor, regression, etc.)
●   Simplifies integration (parts, sum & integration)
●   Documentation (live, understand API)
●   Design (TDD, no formal design, design element)
What is Test Driven Development?
●   a software development process that
    relies on the repetition of a very short
    development cycle: first the developer
    writes a failing automated test case         Test
    that defines a desired improvement or
    new function, then produces code to
    pass that test and finally refactors the        Code
    new code to acceptable standards.
●   Kent Beck, who is credited with            Refactor
    having developed or 'rediscovered'
    the technique, stated in 2003 that
    TDD encourages simple designs and
    inspires confidence.
What is Behavior Driven Development?
●   An agile software development technique that
    encourages collaboration between developers, QA
    and non-technical or business participants in a
    software project.
●   A response to Test Driven Development, including
    Acceptance Test or Customer Test Driven
    Development practices as found in Extreme
    Programming.
●   It extends TDD by writing test cases in a natural
    language that non-programmers can read.
●   With a Feature Injection, BDD covers the analysis
    space and provides a full treatment of the software
    lifecycle from vision through to code and release.
Test Categories
Categories of (Unit) Tests
●   Small: Unit Tests
    ●   Check conditional logic in the code
    ●   A debugger should not be required in case of failure
●   Medium: Functional Tests
    ●   Check whether the interfaces between classes
        abide by their contracts
●   Large: End-to-End Tests
    ●   Check for “wiring bugs”
Software Testing Pyramid
Frameworks
C++              51
C                39
                      Wikipedia:
JavaScript       29   373 testing
Java             27   frameworks in
.NET             23
PHP              11   70 programming
Common Lisp      11   languages
Objective-C       9
Perl              9
ActionScript /    9
Adobe Flex
C++
●   CppUnit       ●   Differences in compilers,
                      platforms, and programming
●   Boost.Test
                      styles. C++ is not exactly a
●   CppUnitLite       clean, fully supported
●   NanoCppUnit       language, with one coding
                      standard.
●   Unit++
                  ●   List of features you want
●   CxxTest
                  ●   Timing support: individual/total
●   Unit Test++
                  ●   Installation, Creation,
                      Modification, etc.
UnitTest++
●   http://unittest-cpp.sourceforge.net/UnitTest++.html
●   Lightweight unit testing framework for C++
●   Designed to do test-driven development on a
    wide variety of platforms
●   Simplicity, portability, speed, and small footprint
●   ANSI portable C++: Win32, Linux, Mac OS X
●   Written and maintained by Charles Nicholson
    and Noel Llopis “C++ For Game Programmers”
UnitTest++ Example
●   a minimal C++ program to run a failing test
    through UnitTest++




    UnitTest++$ g++ -I./src -c test.cpp -o test.o
    UnitTest++$ g++ test.o libUnitTest++.a -o test
    UnitTest++$ ./test
    test.cpp:6: error: Failure in FailSpectacularly: false
    FAILURE: 1 out of 1 tests failed (1 failures).
    Test time: 0.00 seconds.
Java
●   JUnit        ●   Java has an abundance of
                     libraries that can help with the
●   TestNG
                     development of your tests cases
●   JTest        ●   Unit tests are fairly easy to write
●   Cactus           and have very rapid performance,
●   Mockito          so it's not going to take you long
                     to run them.
●   JWalk
                 ●   Don't Sacrifice Design for the
●   SureAssert       Sake of Testing
                 ●   Use Statistical Testing for Non-
                     deterministic Code
JUnit
●   http://junit.sourceforge.net/
●   JUnit is a simple framework to code repeatable
    tests written by Erich Gamma and Kent Beck. It
    is used by the developer who implements unit
    tests in Java. Most famous of XUnits, JUnit is
    Open Source Software.
●   Annotate a method with @org.junit.Test
●   When you want to check a value, import static
    org.junit.Assert.*, call assertTrue() and pass a
    boolean that is true if the test succeeds
JUnit Example
●   a minimal Java class to run a successful test




    junit$ javac -cp junit-4.10.jar MyFirstTest.java
    junit$ java -cp junit-4.10.jar:. org.junit.runner.JUnitCore
    MyFirstTest
    JUnit version 4.10
    Time: 0.004
    OK (1 test)
.NET
●   csUnit      ●   There are a wide variety of unit
                    testing tools available for .NET.
●   MSTest
                    Fortunately, the structure of unit
●   NUnit           tests is similar within most of the
●   NUnitAsp        frameworks.
●   .TEST
                ●   NUnit has historically been one of
                    the most popular frameworks
●   xUnit.net
                ●   There are 2 main parts of a unit
●   Visual          testing system, the testing
    Studio          framework and a test runner.
NUnit
●   http://www.nunit.org/ initially ported from JUnit
●   written entirely in C# and has been completely
    redesigned to take advantage of many .NET
    language features, for example custom
    attributes and other reflection related
    capabilities.
●   NUnit has two different ways to run your tests.
    The console runner, nunit-console.exe, is the
    fastest to launch, but is not interactive. The gui
    runner, nunit.exe, is a Windows Forms
    application that allows you to work selectively
    with your tests and provides graphical feedback
NUnit Example
●   [TestFixture] is the
    way to indicate that
    the class contains
    test code.
●   [Test] is an
    indication that it is a
    test method.
●   TransferFunds : expected
    <250> but was <150>
Perl
●   Test::More    ●   Put your tests in t/ and follow the
                      convention of ##-name.t.
●   TAP
                  ● Create a "Smoke Test" script and
●   Test::Harness
                    a bunch of generic tests
●   Test::Unit    ● Its as simple as deciding what

●   Test::Class     you want to write, writing a test
●   Test::Builder   for what you are going to write,
                    then writing the code that does it
●   Test::Able
                  ● Start of by creating a file called

                    tdd_is_cool.pm and a file called
                    tdd_is_cool.t
Test::More
●   http://search.cpan.org/perldoc?Test::More
●   Yet another framework for writing test scripts
●   By convention, each test is assigned a number
    in order, often very useful to assign a name
●   Before anything else, you need a testing plan
●   use Test::More tests => 23;
●   ... run your tests ...
●   done_testing( $number_of_tests_run );
Test::More Example
●   A simple test module with two tests:
●


●


●


●   test::more$ perl tdd_is_cool.t
●   1..2
●   ok 1 - use tdd_is_cool;
●   ok 2 - TDD is cool!
PHP
●   PHPUnit      ●   As unit testing has gained
                     popularity, it has become a
●   SimpleTest
                     standard practice in PHP with
●   lime             libraries and frameworks such as
●   Atoum            Swiftmailer, the Zend Framework,
                     Yii and Symfony all requiring unit
●   ojes             test coverage of their source code
●   Testilence  Even good programmers make
                 ●

●   Apache-Test mistakes. The difference between
                a good and a bad programmer is
●   OnionTest
                that the good uses tests to detect
                his mistakes as soon as possible
PHPUnit
●   PHPUnit is the de-facto standard for unit testing
    in PHP projects. It provides both a framework
    that makes the writing of tests easy as well as
    the functionality to easily run the tests and
    analyse their results.
●   Part of xUnit family, created by Sebastian
    Bergmann, integrated & supported by Zend
    Studio/Framework.
●   Simple installation with PEAR
Installation
●   PHPUnit should be installed using the PEAR Installer. This installer is
    the backbone of PEAR, which provides a distribution system for PHP
    packages, and is shipped with every release of PHP since version
    4.3.0.
●   The PEAR channel (pear.phpunit.de) that is used to distribute
    PHPUnit needs to be registered with the local PEAR environment.
    Furthermore, components that PHPUnit depends upon are hosted on
    additional PEAR channels.
              pear channel-discover pear.phpunit.de
              pear channel-discover components.ez.no
              pear channel-discover pear.symfony-project.com
●   This has to be done only once. Now the PEAR Installer can be used to
    install packages from the PHPUnit channel:
              pear install phpunit/PHPUnit

●   After the installation you can find the PHPUnit source files inside
    your local PEAR directory; the path is usually /usr/lib/php/PHPUnit.
Unit Testing Zend Framework
●   Let's create a new Zend Framework application:
     zf create project zf-project
First Run
●   Launch an auto-generated unit tests from tests
    directory with the phpunit command:




●   phpunit.xml – testing configuration settings
●   bootstrap.php – load application during testing
IndexController Auto-Generated Test
A Word of Explanation
●   What are the parameters
    ●   URL generated from an Array of parameters
    ●   Are we dispatched to the correct place and result
●   What we were checking in the test
    ●   dispatch – point the URL where we go to
    ●   assertModule – are we in the correct module?
    ●   assertController – checks the controller we are in
    ●   assertAction – checks the action
    ●   assertQueryContentContains – checks the content
Coverage Report
●   Test coverage report(requires XDebug) with
    phpunit –coverage /report/directory/path
Zend Testing Further Reading
●   http://anton.shevchuk.name/php/unit-tests-
    zend-framework-application/
●   You can use DOM assertions:
    ● CSS selectors
    ● XPath


●   Use mock for Zend_Auth
●   Create emulators/wrappers
●   Write more tests!
Recommendation Summary
●   C++         ●   UnitTest++ advanced & convenient
●   Java        ●   JUnit the first and the best
●   .NET        ●   NUnit most popular & rich
●   Perl        ●   Test::More de-facto standard
●   PHP(Zend)   ●   PHPUnit (Zend_Test) must have
Even good programmers make mistakes.
The difference between a good and a bad
programmer is that the good uses tests to
detect his mistakes as soon as possible.
Links
●   http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks
●   http://gamesfromwithin.com/exploring-the-c-unit-testing-
    framework-jungle
●   http://www.testdriven.com/
●   http://www.phpunit.de/manual/3.6/en/index.html
●   https://github.com/sebastianbergmann/phpunit/
●   http://en.wikipedia.org/wiki/Unit_testing
●   http://www.slideshare.net/sebastian_bergmann/getting-started-
    with-phpunit
●   http://anton.shevchuk.name/php/unit-tests-zend-framework-
    application/
●   http://www.slideshare.net/DragonBe/introduction-to-unit-testing-
    with-phpunit-presentation-705447
Ad

More Related Content

What's hot (20)

Automated Testing for Embedded Software in C or C++
Automated Testing for Embedded Software in C or C++Automated Testing for Embedded Software in C or C++
Automated Testing for Embedded Software in C or C++
Lars Thorup
 
Unit testing with Qt test
Unit testing with Qt testUnit testing with Qt test
Unit testing with Qt test
Davide Coppola
 
Presentation_C++UnitTest
Presentation_C++UnitTestPresentation_C++UnitTest
Presentation_C++UnitTest
Raihan Masud
 
Python Testing Fundamentals
Python Testing FundamentalsPython Testing Fundamentals
Python Testing Fundamentals
cbcunc
 
Test all the things! Automated testing with Drupal 8
Test all the things! Automated testing with Drupal 8Test all the things! Automated testing with Drupal 8
Test all the things! Automated testing with Drupal 8
Sam Becker
 
Unit testing on embedded target with C++Test
Unit testing on embedded  target with C++TestUnit testing on embedded  target with C++Test
Unit testing on embedded target with C++Test
Engineering Software Lab
 
Continuous Integration In Php
Continuous Integration In PhpContinuous Integration In Php
Continuous Integration In Php
Wilco Jansen
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under Test
Seb Rose
 
Introduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylightIntroduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylight
OpenDaylight
 
Presentation Unit Testing process
Presentation Unit Testing processPresentation Unit Testing process
Presentation Unit Testing process
Bárbara Cabral da Conceição, CTFL
 
Unit test in drupal 8 by Pratomo Ardianto Drupalcamp Cebu 2018
Unit test in drupal 8 by Pratomo Ardianto Drupalcamp Cebu 2018Unit test in drupal 8 by Pratomo Ardianto Drupalcamp Cebu 2018
Unit test in drupal 8 by Pratomo Ardianto Drupalcamp Cebu 2018
Promet Source
 
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
ICS
 
RPG Program for Unit Testing RPG
RPG Program for Unit Testing RPG RPG Program for Unit Testing RPG
RPG Program for Unit Testing RPG
Greg.Helton
 
Unit Testing RPG with JUnit
Unit Testing RPG with JUnitUnit Testing RPG with JUnit
Unit Testing RPG with JUnit
Greg.Helton
 
PHPUnit with Magento
PHPUnit with MagentoPHPUnit with Magento
PHPUnit with Magento
Tu Hoang
 
Containerize your Blackbox tests
Containerize your Blackbox testsContainerize your Blackbox tests
Containerize your Blackbox tests
Kevin Beeman
 
Unit testing
Unit testingUnit testing
Unit testing
Prabhat Kumar
 
Apache maven, a software project management tool
Apache maven, a software project management toolApache maven, a software project management tool
Apache maven, a software project management tool
Renato Primavera
 
How and what to unit test
How and what to unit testHow and what to unit test
How and what to unit test
Eugenio Lentini
 
Unit testing with NUnit
Unit testing with NUnitUnit testing with NUnit
Unit testing with NUnit
kleinron
 
Automated Testing for Embedded Software in C or C++
Automated Testing for Embedded Software in C or C++Automated Testing for Embedded Software in C or C++
Automated Testing for Embedded Software in C or C++
Lars Thorup
 
Unit testing with Qt test
Unit testing with Qt testUnit testing with Qt test
Unit testing with Qt test
Davide Coppola
 
Presentation_C++UnitTest
Presentation_C++UnitTestPresentation_C++UnitTest
Presentation_C++UnitTest
Raihan Masud
 
Python Testing Fundamentals
Python Testing FundamentalsPython Testing Fundamentals
Python Testing Fundamentals
cbcunc
 
Test all the things! Automated testing with Drupal 8
Test all the things! Automated testing with Drupal 8Test all the things! Automated testing with Drupal 8
Test all the things! Automated testing with Drupal 8
Sam Becker
 
Unit testing on embedded target with C++Test
Unit testing on embedded  target with C++TestUnit testing on embedded  target with C++Test
Unit testing on embedded target with C++Test
Engineering Software Lab
 
Continuous Integration In Php
Continuous Integration In PhpContinuous Integration In Php
Continuous Integration In Php
Wilco Jansen
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under Test
Seb Rose
 
Introduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylightIntroduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylight
OpenDaylight
 
Unit test in drupal 8 by Pratomo Ardianto Drupalcamp Cebu 2018
Unit test in drupal 8 by Pratomo Ardianto Drupalcamp Cebu 2018Unit test in drupal 8 by Pratomo Ardianto Drupalcamp Cebu 2018
Unit test in drupal 8 by Pratomo Ardianto Drupalcamp Cebu 2018
Promet Source
 
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
ICS
 
RPG Program for Unit Testing RPG
RPG Program for Unit Testing RPG RPG Program for Unit Testing RPG
RPG Program for Unit Testing RPG
Greg.Helton
 
Unit Testing RPG with JUnit
Unit Testing RPG with JUnitUnit Testing RPG with JUnit
Unit Testing RPG with JUnit
Greg.Helton
 
PHPUnit with Magento
PHPUnit with MagentoPHPUnit with Magento
PHPUnit with Magento
Tu Hoang
 
Containerize your Blackbox tests
Containerize your Blackbox testsContainerize your Blackbox tests
Containerize your Blackbox tests
Kevin Beeman
 
Apache maven, a software project management tool
Apache maven, a software project management toolApache maven, a software project management tool
Apache maven, a software project management tool
Renato Primavera
 
How and what to unit test
How and what to unit testHow and what to unit test
How and what to unit test
Eugenio Lentini
 
Unit testing with NUnit
Unit testing with NUnitUnit testing with NUnit
Unit testing with NUnit
kleinron
 

Similar to Unit testing (eng) (20)

Writing Tests with the Unity Test Framework
Writing Tests with the Unity Test FrameworkWriting Tests with the Unity Test Framework
Writing Tests with the Unity Test Framework
Peter Kofler
 
Beginners - Get Started With Unit Testing in .NET
Beginners - Get Started With Unit Testing in .NETBeginners - Get Started With Unit Testing in .NET
Beginners - Get Started With Unit Testing in .NET
Baskar K
 
Introduzione a junit + integrazione con archibus
Introduzione a junit + integrazione con archibusIntroduzione a junit + integrazione con archibus
Introduzione a junit + integrazione con archibus
Davide Fella
 
Back to basics - PHPUnit
Back to basics - PHPUnitBack to basics - PHPUnit
Back to basics - PHPUnit
Sebastian Marek
 
Test Driven Development with PHP
Test Driven Development with PHPTest Driven Development with PHP
Test Driven Development with PHP
Rogério Vicente
 
Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...
Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...
Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...
DicodingEvent
 
stackconf 2024 | Test like a ninja with Go by Ivan Presenti.pdf
stackconf 2024 | Test like a ninja with Go by Ivan Presenti.pdfstackconf 2024 | Test like a ninja with Go by Ivan Presenti.pdf
stackconf 2024 | Test like a ninja with Go by Ivan Presenti.pdf
NETWAYS
 
Automation for developers
Automation for developersAutomation for developers
Automation for developers
Dharshana Kasun Warusavitharana
 
Creating a reasonable project boilerplate
Creating a reasonable project boilerplateCreating a reasonable project boilerplate
Creating a reasonable project boilerplate
Stanislav Petrov
 
Write unit test from scratch
Write unit test from scratchWrite unit test from scratch
Write unit test from scratch
Wen-Shih Chao
 
UPC Plone Testing Talk
UPC Plone Testing TalkUPC Plone Testing Talk
UPC Plone Testing Talk
Timo Stollenwerk
 
Introduction to Test Automation
Introduction to Test AutomationIntroduction to Test Automation
Introduction to Test Automation
Pekka Klärck
 
Quality for developers
Quality for developersQuality for developers
Quality for developers
Dharshana Kasun Warusavitharana
 
Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++
Hong Le Van
 
Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Unit testing, UI testing and Test Driven Development in Visual Studio 2012Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Jacinto Limjap
 
Test automation - Building effective solutions
Test automation - Building effective solutionsTest automation - Building effective solutions
Test automation - Building effective solutions
Artem Nagornyi
 
TDD Workshop UTN 2012
TDD Workshop UTN 2012TDD Workshop UTN 2012
TDD Workshop UTN 2012
Facundo Farias
 
PresentationqwertyuiopasdfghUnittest.pdf
PresentationqwertyuiopasdfghUnittest.pdfPresentationqwertyuiopasdfghUnittest.pdf
PresentationqwertyuiopasdfghUnittest.pdf
kndemo34
 
Unit testing
Unit testing Unit testing
Unit testing
dubbu
 
Testing & continuous delivery
Testing & continuous deliveryTesting & continuous delivery
Testing & continuous delivery
Nelson Melina
 
Writing Tests with the Unity Test Framework
Writing Tests with the Unity Test FrameworkWriting Tests with the Unity Test Framework
Writing Tests with the Unity Test Framework
Peter Kofler
 
Beginners - Get Started With Unit Testing in .NET
Beginners - Get Started With Unit Testing in .NETBeginners - Get Started With Unit Testing in .NET
Beginners - Get Started With Unit Testing in .NET
Baskar K
 
Introduzione a junit + integrazione con archibus
Introduzione a junit + integrazione con archibusIntroduzione a junit + integrazione con archibus
Introduzione a junit + integrazione con archibus
Davide Fella
 
Back to basics - PHPUnit
Back to basics - PHPUnitBack to basics - PHPUnit
Back to basics - PHPUnit
Sebastian Marek
 
Test Driven Development with PHP
Test Driven Development with PHPTest Driven Development with PHP
Test Driven Development with PHP
Rogério Vicente
 
Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...
Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...
Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...
DicodingEvent
 
stackconf 2024 | Test like a ninja with Go by Ivan Presenti.pdf
stackconf 2024 | Test like a ninja with Go by Ivan Presenti.pdfstackconf 2024 | Test like a ninja with Go by Ivan Presenti.pdf
stackconf 2024 | Test like a ninja with Go by Ivan Presenti.pdf
NETWAYS
 
Creating a reasonable project boilerplate
Creating a reasonable project boilerplateCreating a reasonable project boilerplate
Creating a reasonable project boilerplate
Stanislav Petrov
 
Write unit test from scratch
Write unit test from scratchWrite unit test from scratch
Write unit test from scratch
Wen-Shih Chao
 
Introduction to Test Automation
Introduction to Test AutomationIntroduction to Test Automation
Introduction to Test Automation
Pekka Klärck
 
Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++
Hong Le Van
 
Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Unit testing, UI testing and Test Driven Development in Visual Studio 2012Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Jacinto Limjap
 
Test automation - Building effective solutions
Test automation - Building effective solutionsTest automation - Building effective solutions
Test automation - Building effective solutions
Artem Nagornyi
 
PresentationqwertyuiopasdfghUnittest.pdf
PresentationqwertyuiopasdfghUnittest.pdfPresentationqwertyuiopasdfghUnittest.pdf
PresentationqwertyuiopasdfghUnittest.pdf
kndemo34
 
Unit testing
Unit testing Unit testing
Unit testing
dubbu
 
Testing & continuous delivery
Testing & continuous deliveryTesting & continuous delivery
Testing & continuous delivery
Nelson Melina
 
Ad

More from Anatoliy Okhotnikov (18)

Agile (IF PM Group) v2
Agile (IF PM Group) v2Agile (IF PM Group) v2
Agile (IF PM Group) v2
Anatoliy Okhotnikov
 
Xdebug (ukr)
Xdebug (ukr)Xdebug (ukr)
Xdebug (ukr)
Anatoliy Okhotnikov
 
iPhone Objective-C Development (ukr) (2009)
iPhone Objective-C Development (ukr) (2009)iPhone Objective-C Development (ukr) (2009)
iPhone Objective-C Development (ukr) (2009)
Anatoliy Okhotnikov
 
Web application security (eng)
Web application security (eng)Web application security (eng)
Web application security (eng)
Anatoliy Okhotnikov
 
Php web app security (eng)
Php web app security (eng)Php web app security (eng)
Php web app security (eng)
Anatoliy Okhotnikov
 
User story workflow (eng)
User story workflow (eng)User story workflow (eng)
User story workflow (eng)
Anatoliy Okhotnikov
 
Ubuntu server wireless access point (eng)
Ubuntu server wireless access point (eng)Ubuntu server wireless access point (eng)
Ubuntu server wireless access point (eng)
Anatoliy Okhotnikov
 
Project Management: Burn-Down Chart / OrangeHRM Project MOD (eng)
Project Management: Burn-Down Chart / OrangeHRM Project MOD (eng)Project Management: Burn-Down Chart / OrangeHRM Project MOD (eng)
Project Management: Burn-Down Chart / OrangeHRM Project MOD (eng)
Anatoliy Okhotnikov
 
Ldap introduction (eng)
Ldap introduction (eng)Ldap introduction (eng)
Ldap introduction (eng)
Anatoliy Okhotnikov
 
Linux introduction (eng)
Linux introduction (eng)Linux introduction (eng)
Linux introduction (eng)
Anatoliy Okhotnikov
 
Jenkins CI (ukr)
Jenkins CI (ukr)Jenkins CI (ukr)
Jenkins CI (ukr)
Anatoliy Okhotnikov
 
ITIL (ukr)
ITIL (ukr)ITIL (ukr)
ITIL (ukr)
Anatoliy Okhotnikov
 
ITEvent: Kanban Intro (ukr)
ITEvent: Kanban Intro (ukr)ITEvent: Kanban Intro (ukr)
ITEvent: Kanban Intro (ukr)
Anatoliy Okhotnikov
 
ITEvent: Continuous Integration (ukr)
ITEvent: Continuous Integration (ukr)ITEvent: Continuous Integration (ukr)
ITEvent: Continuous Integration (ukr)
Anatoliy Okhotnikov
 
Debug (ukr)
Debug (ukr)Debug (ukr)
Debug (ukr)
Anatoliy Okhotnikov
 
Db design (ukr)
Db design (ukr)Db design (ukr)
Db design (ukr)
Anatoliy Okhotnikov
 
Continuous integration (eng)
Continuous integration (eng)Continuous integration (eng)
Continuous integration (eng)
Anatoliy Okhotnikov
 
Agile Feedback Loops (ukr)
Agile Feedback Loops (ukr)Agile Feedback Loops (ukr)
Agile Feedback Loops (ukr)
Anatoliy Okhotnikov
 
Ad

Recently uploaded (20)

Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 

Unit testing (eng)

  • 2. Softjourn Inc. Unit Testing Anatoliy Okhotnikov Softjourn Inc.
  • 3. Agenda ● What is Unit Testing? ● Benefits ● What is Test Driven Development? ● What is Behavior Driven Development? ● Categories of (Unit) Tests / Software Testing Pyramid, Frameworks ● C++, Java, .NET, Perl, PHP frameworks ● Unit-testing Zend Framework application
  • 4. What is Unit Testing? ● Ford new engine test area ● Special test harness that connects a gas and oil line ● For the output, a measuring device is connected to the drive shaft that comes directly out of the engine ● Engine starts and revs up ● Within about 5 minutes the computer is able to analyze the torque curve, gas usage, and oil usage
  • 5. What is Unit Testing? ● In computer programming, unit testing is a method by which individual units of source code are tested to determine if they are fit for use. A unit is the smallest testable part of an application. In procedural programming a unit may be an individual function or procedure. Unit tests are created by programmers or occasionally by white box testers. ● Ideally, each test case is independent from the others: substitutes like method stubs, mock objects, fakes and test harnesses can be used to assist testing a module in isolation. Unit tests are typically written and run by software developers to ensure that code meets its design and behaves as intended. Its implementation can vary from being very manual (pencil and paper) to being formalized as part of build automation
  • 6. Benefits The goal of unit testing is to isolate each part of the program and show that the individual parts are correct. A unit test provides a strict, written contract that the piece of code must satisfy. As a result, it affords several benefits. ● Find problems early (in the development cycle) ● Facilitates change (refactor, regression, etc.) ● Simplifies integration (parts, sum & integration) ● Documentation (live, understand API) ● Design (TDD, no formal design, design element)
  • 7. What is Test Driven Development? ● a software development process that relies on the repetition of a very short development cycle: first the developer writes a failing automated test case Test that defines a desired improvement or new function, then produces code to pass that test and finally refactors the Code new code to acceptable standards. ● Kent Beck, who is credited with Refactor having developed or 'rediscovered' the technique, stated in 2003 that TDD encourages simple designs and inspires confidence.
  • 8. What is Behavior Driven Development? ● An agile software development technique that encourages collaboration between developers, QA and non-technical or business participants in a software project. ● A response to Test Driven Development, including Acceptance Test or Customer Test Driven Development practices as found in Extreme Programming. ● It extends TDD by writing test cases in a natural language that non-programmers can read. ● With a Feature Injection, BDD covers the analysis space and provides a full treatment of the software lifecycle from vision through to code and release.
  • 10. Categories of (Unit) Tests ● Small: Unit Tests ● Check conditional logic in the code ● A debugger should not be required in case of failure ● Medium: Functional Tests ● Check whether the interfaces between classes abide by their contracts ● Large: End-to-End Tests ● Check for “wiring bugs”
  • 12. Frameworks C++ 51 C 39 Wikipedia: JavaScript 29 373 testing Java 27 frameworks in .NET 23 PHP 11 70 programming Common Lisp 11 languages Objective-C 9 Perl 9 ActionScript / 9 Adobe Flex
  • 13. C++ ● CppUnit ● Differences in compilers, platforms, and programming ● Boost.Test styles. C++ is not exactly a ● CppUnitLite clean, fully supported ● NanoCppUnit language, with one coding standard. ● Unit++ ● List of features you want ● CxxTest ● Timing support: individual/total ● Unit Test++ ● Installation, Creation, Modification, etc.
  • 14. UnitTest++ ● http://unittest-cpp.sourceforge.net/UnitTest++.html ● Lightweight unit testing framework for C++ ● Designed to do test-driven development on a wide variety of platforms ● Simplicity, portability, speed, and small footprint ● ANSI portable C++: Win32, Linux, Mac OS X ● Written and maintained by Charles Nicholson and Noel Llopis “C++ For Game Programmers”
  • 15. UnitTest++ Example ● a minimal C++ program to run a failing test through UnitTest++ UnitTest++$ g++ -I./src -c test.cpp -o test.o UnitTest++$ g++ test.o libUnitTest++.a -o test UnitTest++$ ./test test.cpp:6: error: Failure in FailSpectacularly: false FAILURE: 1 out of 1 tests failed (1 failures). Test time: 0.00 seconds.
  • 16. Java ● JUnit ● Java has an abundance of libraries that can help with the ● TestNG development of your tests cases ● JTest ● Unit tests are fairly easy to write ● Cactus and have very rapid performance, ● Mockito so it's not going to take you long to run them. ● JWalk ● Don't Sacrifice Design for the ● SureAssert Sake of Testing ● Use Statistical Testing for Non- deterministic Code
  • 17. JUnit ● http://junit.sourceforge.net/ ● JUnit is a simple framework to code repeatable tests written by Erich Gamma and Kent Beck. It is used by the developer who implements unit tests in Java. Most famous of XUnits, JUnit is Open Source Software. ● Annotate a method with @org.junit.Test ● When you want to check a value, import static org.junit.Assert.*, call assertTrue() and pass a boolean that is true if the test succeeds
  • 18. JUnit Example ● a minimal Java class to run a successful test junit$ javac -cp junit-4.10.jar MyFirstTest.java junit$ java -cp junit-4.10.jar:. org.junit.runner.JUnitCore MyFirstTest JUnit version 4.10 Time: 0.004 OK (1 test)
  • 19. .NET ● csUnit ● There are a wide variety of unit testing tools available for .NET. ● MSTest Fortunately, the structure of unit ● NUnit tests is similar within most of the ● NUnitAsp frameworks. ● .TEST ● NUnit has historically been one of the most popular frameworks ● xUnit.net ● There are 2 main parts of a unit ● Visual testing system, the testing Studio framework and a test runner.
  • 20. NUnit ● http://www.nunit.org/ initially ported from JUnit ● written entirely in C# and has been completely redesigned to take advantage of many .NET language features, for example custom attributes and other reflection related capabilities. ● NUnit has two different ways to run your tests. The console runner, nunit-console.exe, is the fastest to launch, but is not interactive. The gui runner, nunit.exe, is a Windows Forms application that allows you to work selectively with your tests and provides graphical feedback
  • 21. NUnit Example ● [TestFixture] is the way to indicate that the class contains test code. ● [Test] is an indication that it is a test method. ● TransferFunds : expected <250> but was <150>
  • 22. Perl ● Test::More ● Put your tests in t/ and follow the convention of ##-name.t. ● TAP ● Create a "Smoke Test" script and ● Test::Harness a bunch of generic tests ● Test::Unit ● Its as simple as deciding what ● Test::Class you want to write, writing a test ● Test::Builder for what you are going to write, then writing the code that does it ● Test::Able ● Start of by creating a file called tdd_is_cool.pm and a file called tdd_is_cool.t
  • 23. Test::More ● http://search.cpan.org/perldoc?Test::More ● Yet another framework for writing test scripts ● By convention, each test is assigned a number in order, often very useful to assign a name ● Before anything else, you need a testing plan ● use Test::More tests => 23; ● ... run your tests ... ● done_testing( $number_of_tests_run );
  • 24. Test::More Example ● A simple test module with two tests: ● ● ● ● test::more$ perl tdd_is_cool.t ● 1..2 ● ok 1 - use tdd_is_cool; ● ok 2 - TDD is cool!
  • 25. PHP ● PHPUnit ● As unit testing has gained popularity, it has become a ● SimpleTest standard practice in PHP with ● lime libraries and frameworks such as ● Atoum Swiftmailer, the Zend Framework, Yii and Symfony all requiring unit ● ojes test coverage of their source code ● Testilence Even good programmers make ● ● Apache-Test mistakes. The difference between a good and a bad programmer is ● OnionTest that the good uses tests to detect his mistakes as soon as possible
  • 26. PHPUnit ● PHPUnit is the de-facto standard for unit testing in PHP projects. It provides both a framework that makes the writing of tests easy as well as the functionality to easily run the tests and analyse their results. ● Part of xUnit family, created by Sebastian Bergmann, integrated & supported by Zend Studio/Framework. ● Simple installation with PEAR
  • 27. Installation ● PHPUnit should be installed using the PEAR Installer. This installer is the backbone of PEAR, which provides a distribution system for PHP packages, and is shipped with every release of PHP since version 4.3.0. ● The PEAR channel (pear.phpunit.de) that is used to distribute PHPUnit needs to be registered with the local PEAR environment. Furthermore, components that PHPUnit depends upon are hosted on additional PEAR channels. pear channel-discover pear.phpunit.de pear channel-discover components.ez.no pear channel-discover pear.symfony-project.com ● This has to be done only once. Now the PEAR Installer can be used to install packages from the PHPUnit channel: pear install phpunit/PHPUnit ● After the installation you can find the PHPUnit source files inside your local PEAR directory; the path is usually /usr/lib/php/PHPUnit.
  • 28. Unit Testing Zend Framework ● Let's create a new Zend Framework application: zf create project zf-project
  • 29. First Run ● Launch an auto-generated unit tests from tests directory with the phpunit command: ● phpunit.xml – testing configuration settings ● bootstrap.php – load application during testing
  • 31. A Word of Explanation ● What are the parameters ● URL generated from an Array of parameters ● Are we dispatched to the correct place and result ● What we were checking in the test ● dispatch – point the URL where we go to ● assertModule – are we in the correct module? ● assertController – checks the controller we are in ● assertAction – checks the action ● assertQueryContentContains – checks the content
  • 32. Coverage Report ● Test coverage report(requires XDebug) with phpunit –coverage /report/directory/path
  • 33. Zend Testing Further Reading ● http://anton.shevchuk.name/php/unit-tests- zend-framework-application/ ● You can use DOM assertions: ● CSS selectors ● XPath ● Use mock for Zend_Auth ● Create emulators/wrappers ● Write more tests!
  • 34. Recommendation Summary ● C++ ● UnitTest++ advanced & convenient ● Java ● JUnit the first and the best ● .NET ● NUnit most popular & rich ● Perl ● Test::More de-facto standard ● PHP(Zend) ● PHPUnit (Zend_Test) must have Even good programmers make mistakes. The difference between a good and a bad programmer is that the good uses tests to detect his mistakes as soon as possible.
  • 35. Links ● http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks ● http://gamesfromwithin.com/exploring-the-c-unit-testing- framework-jungle ● http://www.testdriven.com/ ● http://www.phpunit.de/manual/3.6/en/index.html ● https://github.com/sebastianbergmann/phpunit/ ● http://en.wikipedia.org/wiki/Unit_testing ● http://www.slideshare.net/sebastian_bergmann/getting-started- with-phpunit ● http://anton.shevchuk.name/php/unit-tests-zend-framework- application/ ● http://www.slideshare.net/DragonBe/introduction-to-unit-testing- with-phpunit-presentation-705447