QaFoo Blog: Outside-In Testing and the Adapter and Facade Patterns

The QaFoo blog has a post today about outside-in testing, two design patterns – Adapter and Facade – and how they relate.

As part of our workshops on Test-Driven Development we explain to our customers how testing from the outside-in can help find the right test-mix.

The technique puts a focus on test-driven-development, but instead of the traditional approach starts at the acceptance test level. The first test for a feature is an acceptance test and only then the feature is implemented from the outside classes first. […] Outside-In testing leads to interfaces that are written from what is useful for the client object using them, in contrast to objects that are composed of collaborators that already exist. Because at some point we have to interact with objects that exist already, we will need three techniques to link those newly created interfaces/roles to existing code in our project

These three techniques are:

  • using the adapter pattern to interface with third party code
  • the facade pattern to "layer" your own code
  • continuous refactoring of interfaces/implementations

In this post they focus mostly on the adapter pattern. They show how to use it in interfacing with remote systems in a Symfony application (for example) based on a remote XML file. They also include the test to verify it’s functioning correctly and the PHP code to make the mocks and interfaces you’ll need for the test.

PHPDeveloper.org

Toptal.com: Jumpstart Your PHP Testing with Codeception

The Toptal.com blog has posted a new tutorial that wants to help you make the most of your application via testing. They show you how to use Codeception to create a set of tests to ensure your application is working as expected.

Before moving on to Codeception and PHP, we should cover the basics and start by explaining why we need testing in applications in the first place. Perhaps we could complete a project without wasting time on tests, at least this time?

Sure, you don’t need tests for everything; for example, when you want to build yet another homepage. […] However, you definitely do need testing when: your team uses BDD/TDD, your Git repo contains more than a couple commits, [and] you are a proper professional, working on a serious project.

They start with a look at the kinds of things testing solves in your development process and the different kinds of tests you can create. From there they introduce Codeception, an alternative testing tool to the widely used PHPUnit. The tutorial helps you get it installed and shows you how to make a simple, first test. It helps you execute the test, debug issues that might pop up and the different assertions you can use. With the fundamentals in place, they move on to more details on using it for functional and unit testing.

PHPDeveloper.org

Amine Matmati: Testing PDF content with PHP and Behat

In this post to his site Amine Matmati shows you how to use Behat (with a bit of additional PHP) to test the contents of a rendered PDF file.

If you have a PDF generation functionality in your app, and since most of the libraries out there build the PDF content in an internal structure before outputting it to the file system (FPDF, TCPDF). A good way to write a test for it is to test the output just before the rendering process.

Recently however, and due to this process being a total pain in the ass, people switched to using tools like wkhtmltopdf or some of its PHP wrappers (phpwkhtmltopdf, snappy) that let you build your pages in html/css and use a browser engine to render the PDF for you, and while this technique is a lot more developer friendly, you loose control over the building process.

He shows how to get all of the required software installed including the smalot/pdfparser library used to read in the contents of the PDF file. He initializes a Behat test directory and writes a simple test, checking for a string of some "Lorem ipsum" text in the document’s title and that it contains only one page. Some additional methods have to be created to integrate the PDF parsing and string location/page counting and code is included for each. When all the pieces are put in place, executing the test passes for both checks. You can find the code for the tutorial in this repository that also includes two sample PDFs to work with.

PHPDeveloper.org

Hafiz Waheeduddin Ahmad: API Testing: Installing and Using Codeception

Hafiz Waheeduddin Ahmad has a new post to his site, part three of a series he’s posted on API testing, looking at the use of Codeception for testing API output and functionality.

In this post, we will have a look on how we can use Codeception for API testing.

He starts by helping you get Codeception installed through Composer through a „require“ command line call. He then walks you through the setup of the project and how to use the „codecept“ command line tool. He covers the generated directory structure the bootstrapping created and how to set up a sample configuration for your API. He then gets into writing an example test, showing how to check things like authentication, HTTP header information, response codes and response contents. Finally he shows how to run the tests in both a normal and more verbose way.

Link: http://haafiz.me/development/api-testing-installing-and-using-codeception
PHPDeveloper.org

SitePoint PHP Blog: Grumpy Programmer’s Testing Bundle: Review

The SitePoint PHP blog has posted a book review of a book bundle from the „Grumpy Programmer“ (aka Chris Hartjes) with content about testing – how to test, what to test and creating testable applications.

After having gotten some constructive feedback regarding my testing practices on the basic TDD in your new PHP package tutorial, I decided to read Chris Hartjes „Grumpy Testing Bundle„, a set of two books consisting of The Grumpy Programmer’s Guide To Building Testable PHP Applications and The Grumpy Programmer’s PHPUnit Cookbook. It was my hope that those books will prevent me from using the shoddy practices I displayed in that original post and which originally prompted Matthew Weier O’Phinney’s critique. In this post, I’d like to share with you what I’ve learned, and how much this helped me, if at all.

He breaks down the bundle and talks about each of the two books separately, pointing out places he thought were most useful and others where he felt it needed updates/more clarification. He includes examples of some of the code shared in the books as illustrations and what kind of overall rating he gives it (in elePHPants naturally).

Link: http://www.sitepoint.com/grumpy-programmers-testing-bundle-review/
PHPDeveloper.org

SkyTechGeek.com: 10 aussergewöhnliche Werkzeuge für die Webseite Testing

Manchmal ein wenig (extern) Test Ihrer Website ist in Ordnung und Gagan Chhatwal hat geschrieben seine Liste der zehn-Tools können Sie verwenden, um alles aus, wie viel Last der Website können auf das, was kann getan werden, um die Ladezeit zu optimieren nehmen zu überprüfen.

Bei der Pflege oder Laufen einer Website, müssen Webmaster zu beachten, dass eine der relevantesten Themen, die sie benötigen, um sich auf Folgendes konzentrieren wird: Website Testing, die nicht nur lebenswichtig für die Website selbst, sondern für den Benutzer als auch, und man sollte nicht übersehen seine Bedeutung. [Wir haben] einige wichtige und kostenlose Website Testing-Tools, die Webmaster bei der Prüfung ihrer Websites spart Benutzer zeitaufwendig unnötige Recherchen bei der Suche nach den besten Ressourcen in Bezug auf Web zugehörigen Tools und Informationen führen dazu beitragen gesammelt.

Zu den Tools auf der Liste sind Dienstleistungen wie:

Die meisten dieser Ressourcen sind kostenlos, wenn nicht dann einen Versuch haben, wo man sehen kann, wenn es eine gute Passform ist.

PHPDeveloper.org

Bradley Holt Blog: Testing PHP 5,4

Bradley Holt hat einen neuen Beitrag in seinem Blog heute sprechen über die Erfahrungen, die er mit Prüfung der PHP 5,4 alpha1 Version , gerade aus dem PHP Development Group geschrieben.

Rasmus Lerdorf Heute posted Anweisungen zur Prüfung der kommenden PHP Version 5.4 . Das Ausführen des PHP-Tests und der Vorlage der dazugehörigen Bericht wird dazu beitragen, das PHP-Team bekommen PHP 5,4 ready schneller als es ihnen Berichte über fehlgeschlagene Tests aus einer Vielzahl von Plattformen. Ich habe gerade das heute zum ersten Mal und kann Ihnen sagen, dass es sehr einfach ist. Im Folgenden sind die Schritte, die Rasmus umrissen, in ein wenig mehr Details.

Er nennt ein paar Dinge, die Sie benötigen, bevor Sie beginnen und erhalten, wo sich diese neuesten Code aus greifen werde. Er beschreibt die make / make test Prozess und was man zu sehen, wenn einer der Tests fehl. Sie können die Ergebnisse des fehlgeschlagenen Tests Einreichungen auf den Test finden Reports Seite .

PHPDeveloper.org

Warren Tang Blog: PHP Unit Testing & Mock Objects mit SimpleTest Plugin für Eclipse

Warren Tang hat zusammen diese neue post in seinem Blog zeigt, wie Sie die SimpleTest Erweiterung für Eclipse verwenden zu führen die Tests ohne die IDE zu verlassen.

Er zerlegt es in ein paar einfachen Schritten (teilweise mit Screenshots hinzufügen):

  • Download das Plugin
  • Installieren und konfigurieren
  • Erstellen eines einfachen Test mit einer Behauptung
  • Führen Sie den Test über „Wie> SimpleTest Run“

Er beinhaltet auch die Option zur Durchführung des Tests, wie eine Web-Seite, aber das erfordert ein bisschen mehr Code. Es gibt auch einen kurzen Blick auf, wie eine Reihe von Tests aus der IDE (wie auch in den Browser) ausgeführt werden. Für weitere Informationen zur Verwendung SimpleTest, über Kopf zu des Projekts vor Ort .

PHPDeveloper.org