Szczegóły ebooka

Instant Hands-on Testing with PHPUnit How-to. A practical guide to getting started with PHPUnit to improve code quality

Instant Hands-on Testing with PHPUnit How-to. A practical guide to getting started with PHPUnit to improve code quality

Michael Lively

Ebook
No developer wants to accept the inherent difficulty of writing software as an excuse for not finding the bugs in our code before anyone else does. PHPUnit is a framework that was created to allow developers to solve that very problem. It provides a feature-rich environment with most of the tools necessary to provide adequate tests for any project.

Instant Hands-on Testing with PHPUnit How-to provides a thorough overview of the functionality provided by the PHPUnit framework. It shows how the plethora of features in the framework can be used to write tests for real world projects to ensure they function and will continue to function in the ways that you expect.

This book will show how you can set up the scaffolding necessary to run unit tests in your project with PHPUnit. It will walk you through the process of how to write a basic test and how to maintain your project's test suite. You will learn how to use some of the more advanced features of PHPUnit and then see how you can use mock objects to isolate the code you are testing. We will then discover how to create tests that verify your interaction with databases and even see how you can use PHPUnit to understand which code you are actually testing.

At the end of the book you will have all of the basic understanding necessary to begin adding tests to your project. This book provides a great foundation for becoming a expert at writing unit tests.
  • Instant Hands-on Testing with PHPUnit How-to
    • Instant Hands-on Testing with PHPUnit How-to
    • Credits
    • About the Author
    • About the Reviewers
    • www.PacktPub.com
      • Support files, eBooks, discount offers and more
        • Why Subscribe?
        • Free Access for Packt account holders
    • Preface
      • What this book covers
      • What you need for this book
      • Who this book is for
      • Conventions
      • Reader feedback
      • Customer support
        • Downloading the example code
        • Errata
        • Piracy
        • Questions
    • 1. Instant Hands-on Testing with PHPUnit How-to
      • Installing PHPUnit (Simple)
        • How to do it...
        • How it works...
        • Theres more...
          • Installing PHPUnit using Composer
          • Installing PHPUnit on older versions of PHP
      • Writing your first test (Simple)
        • Getting ready...
        • How to do it...
        • How it works...
        • There's more...
          • Class names
      • Running tests (Simple)
        • How to do it...
        • How it works...
        • There's more...
          • Command line options
            • --colors
            • --stop-on-error and --stop-on-failure
            • --debug
            • --strict
      • Configuring PHPUnit (Simple)
        • How to do it...
        • How it works...
        • There's more...
          • Additional configurations
          • Using phpunit.xml.dist
      • Adding PHPUnit to your project (Simple)
        • Getting ready...
        • How to do it
        • How it works
        • There's more...
      • Generating tests from code (Advanced)
        • Getting ready
        • How to do it...
        • How it works...
        • There's more...
          • Using @assert to generate additional code
          • Using the Skeleton Generator for test-driven development
      • Using test fixtures (Simple)
        • How to do it...
        • How it works...
        • There's more...
      • Using data providers (Intermediate)
        • How to do it...
        • How it works...
          • Identifying test failures
      • Using test dependencies (Advanced)
        • How to do it...
        • How it works...
          • Multiple test dependencies
          • Multiple dependent tests
      • Using mock objects (Simple)
        • How to do it...
        • How it works...
        • There's more...
          • Thoughts on partial mocks
          • Ignoring parameters on method expectations
          • Stubbing exceptions
          • Stubbing multiple return values
          • Stubbing with callbacks
          • Using mock builders
          • Using alternative mock frameworks
            • Phake
            • Mockery
      • Testing abstract classes (Intermediate)
        • How to do it...
        • How it works...
          • Abstract classes in Phake
      • Testing traits (Intermediate)
        • How to do it...
        • How it works...
      • Testing exceptions and errors (Intermediate)
        • How to do it...
        • How it works...
        • There's more...
      • Testing output (Intermediate)
        • How to do it...
        • How it works...
        • There's more...
      • Testing protected and private methods (Intermediate)
        • How to do it...
        • How it works...
          • Private and protected methods
      • Testing database interaction (Advanced)
        • Getting ready
        • How to do it...
        • How it works...
        • There's more...
          • Alternate data sets
            • Flat XML data set
            • MySQL XML data set
            • YAML data set
          • Validating your data with queries
      • Viewing code coverage (Advanced)
        • Getting ready
        • How to do it...
        • How it works...
  • Tytuł: Instant Hands-on Testing with PHPUnit How-to. A practical guide to getting started with PHPUnit to improve code quality
  • Autor: Michael Lively
  • Tytuł oryginału: Instant Hands-on Testing with PHPUnit How-to. A practical guide to getting started with PHPUnit to improve code quality
  • ISBN: 9781782169598, 9781782169598
  • Data wydania: 2013-05-23
  • Format: Ebook
  • Identyfikator pozycji: e_2x3z
  • Wydawca: Packt Publishing