Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

PHP Roundtable:
055: Acceptance Testing with Behat
Nov 08, 2016 @ 17:56:10

The PHP Rountable podcast has posted its latest episode featuring a discussion about Behat and acceptance testing in your PHP applications. This time host Sammy Powers is joined by Jessica Mauerhan and Konstantin Kudryashov.

We chat about the open-source Behavior-Driven Development framework called Behat. We get a brief overview of how Behat can help us write more reliable code and also explore some best-practices when writing automated tests.

You can catch this episode in a few different ways - either using the in-page audio or video player or you can watch the live recording (Google Hangout) directly over on YouTube. If you enjoy the show be sure to subscribe to their feed and follow them on Twitter for updates when new shows are released and when the next shows will be recorded.

tagged: phproundtable podcast video behat acceptance testing behaviordriven development

Link: https://www.phproundtable.com/episode/acceptance-testing-with-behat

Semaphore CI Blog:
Getting Started with BDD in Laravel
Aug 05, 2015 @ 14:17:43

Bruno Skvorc has written up a tutorial on the Semaphore-CI blog showing you how to get started with behavior-driven development in Laravel applications. He makes use of the Behat and PHPSpec libraries to write and execute the tests.

For many developers BDD is a complicated subject, and getting started with it the right way often does not come easy - especially when you need to implement it into an existing framework. This tutorial aims to help you get a BDD-powered Laravel project up and running in very little time, introducing you to the basic concepts and workflow you'll need to proceed on your own. We'll be installing and using Behat and PhpSpec.

He walks you through the process of getting everything you need installed: a simple Laravel application and Behat (also requiring a bit of setup to make it "play nice" with Laravel). He initializes the Behat directory and explains the concept of "context" and how to configure your Behat installation. He then gets into writing the features, creating a basic test that checks the main page of the Laravel application for the phrase "Laravel 5". A bit of additional PHP code is required to make the tests work (included) and the result is a passing test, executed with just a behat command.

The second half of the article is about PHPSpec, showing how it can be used as a sort of replacement for PHPUnit with a bit more readable syntax. He shows how to write a simple test against an object. Finally, he shows how to combine the powers of Behat and PHPSpec into a single method of testing, using PHPSpec behind the scenes in the Behat context to help with testing assertions.

tagged: phpunit phpspec testing behaviordriven behat bdd introduction tutorial

Link: https://semaphoreci.com/community/tutorials/getting-started-with-bdd-in-laravel

Jani Hartikainen:
What’s the difference between Unit Testing, TDD and BDD?
Mar 02, 2015 @ 15:16:28

On his site today Jani Hartikainen has a new post helping to demystify some potential confusion around unit testing, test-driven development and behavior-driven development. He's talking about them in the context of Javascript in this case, but the fundamentals transfer to just about any other language, including PHP.

When you’re just getting started with automating your JavaScript testing, there’s a lot of questions. You’ll probably see people talk about unit testing, TDD or Test-Driven Development, and BDD or Behavior-Driven Development. But which one of them is the best approach? Can you use all of them? I’ve talked to a number of JavaScript developers, and there seems to be some confusion about all this. So, let’s take a look at Unit testing, TDD and BDD, and fix some of the common misconceptions about them out there.

For each he provides an overview of this basic concepts and a bit of sample code showing it in action. For TDD (test-driven development) there's not really a way to show it specifically in code as it's more of a practice. Instead he gives a "checklist" to follow when practicing it.

Unit Testing gives you the what. Test-Driven Development gives you the when. Behavior Driven-Development gives you the how. Although you can use each individually, you should combine them for best results as they complement each other very nicely.
tagged: bdd unittest tdd testdrive behaviordriven development introduction

Link: http://codeutopia.net/blog/2015/03/01/unit-testing-tdd-and-bdd/

NetTus.com:
Understanding PhpSpec
Sep 04, 2014 @ 16:09:42

The NetTuts.com site (well, TutsPlus) has posted a new tutorial that gets you more intimate with PhpSpec, a PHP-based testing tool that lets you define tests as specifications and using behavior-driven development principles. If you need an introduction to the tool, check out this other tutorial first.

If you compare PhpSpec to other testing frameworks, you will find that it is a very sophisticated and opinionated tool. One of the reasons for this, is that PhpSpec is not a testing framework like the ones you already know. Instead, it is a design tool that helps describing behavior of software. A side effect of describing the behavior of software with PhpSpec, is that you will end up with specs that will also serve as tests afterwards. In this article, we will take a look under the hood of PhpSpec and try to gain a deeper understanding of how it works and how to use it.

They provide a quick overview of some of the internals of the PhpSpec tool and a brief look at the difference between BDD (behavior-driven) and TDD (test-driven) development practices. There's also a look at how the tool differs from the popular PHP testing tool PHPUnit. Code examples are provided through out the post with simple tests, making the separation between the methods and tools easier to follow.

tagged: tutorial phpspec testing tool bdd tdd unittest behaviordriven development

Link: http://code.tutsplus.com/tutorials/understanding-phpspec--cms-21915

NetTuts.com:
Getting Started With Phpspec
May 12, 2014 @ 18:55:10

The NetTuts.com site has a new tutorial that want to help get you started with PHPSpec, the PHP-based tool to help with behavior-driven development.

In this short, yet comprehensive, tutorial, we'll have a look at behavior driven development (BDD) with phpspec. Mostly, it will be an introduction to the phpspec tool, but as we go, we'll touch on different BDD concepts. BDD is a hot topic these days and phpspec has gained a lot of attention in the PHP community recently.

They briefly introduce behavior-driven development (BDD) and where the PHPSpec tool fits into the picture. They guide you through installation of the tool (via Composer) and some configuration updates to get things set up. From there, they help you write your first spec, a test to see if a "TaskCollection" can be created. They build on this simple test adding in checks for adding tasks, making the collection countable and working with expectations and promises. The last part of the tutorial mentions how to make custom matchers like "beTrue" and "beFalse" and the output of the full test set.

tagged: phpspec tutorial introduction behaviordriven development bdd

Link: http://code.tutsplus.com/tutorials/getting-started-with-phpspec--cms-20919

Gonzalo Ayuso:
Building a BDD framework with PHP
Aug 19, 2013 @ 14:49:57

<p. Gonzalo Ayuso wanted to look into BDD (behavior driven development) in PHP and was looking around for a tool to fit his needs. He didn't find one right away and so decided to create a simple one as a proof of concept to try out the method for himself.

I want to write as less code as I can (it’s only a proof of concept), so I will reuse the assertion framework or PHPUnit. As I’ve seen when studying Behat, we can use the assertion part as standalone functions. We only need to include vendor/phpunit/phpunit/PHPUnit/Framework/Assert/Functions.php file.

He includes the sample code showing his basic interface - a string calculation object being passed into a closure for evaluation by the PHPUnit assertion methods. He also includes an example of using it along with Mockery for creating a mock object and testing based on that.

tagged: bdd behaviordriven development framework proofofconcept poc mockery

Link: http://gonzalo123.com/2013/08/19/building-a-bdd-framework-with-php

Francesco Tassi:
Switching From TDD to BDD With Behat and Symfony2
Aug 16, 2013 @ 18:27:32

In this new post to his site Francesco Tassi shares his experience making the switch from doing just test-driven development on his Symfony2-based applications to behavior-driven development using Behat, Mink and PHPSpec.

Recently I started a small extra project with a smart fellow from my local PHP User Group, since the project was quite simple and both of us were willing to learn something new, we decided to give BDD a try. In the PHP world BDD means Behat, Mink and PHPSpec. [...] In this post I won’t cover all the details about BDD, Behat or PHPSpec, I’d rather describe how I switched from PHPUnit and TDD to BDD (and also show some bits of code).

He talks about the switch in mindset that comes along with adopting BDD and how you think about testing - not what it does, but what it should do. He talks some about test organization, configuration and his process for executing them. There's a bit about working with databases (with fixtures and @BeforeScenario) including the code for the feature file to make it happen.

tagged: tdd testdriven bdd behaviordriven behat symfony2 tutorial

Link: http://www.ftassi.com/blog/2013/08/12/switching-from-tdd-to-bdd-with-behat-and-symfony2

QaFoo.com:
Webinar: Behavior Driven Development with Behat
Apr 17, 2013 @ 15:44:21

The QaFoo folks have posted information about a webinar they're putting on for those interested in using Behat for doing functional testing on their applications:

I've already written two blog posts here about Behat: Behavior Driven Development and Code Coverage with Behat. If that made you curious or you wanted to learn about Behat anyway, I can highly recommend to join the free webinar on Behavior Driven Development with Behat I'll be giving on May 8th 2013 on behalf of Qafoo in cooperation with Zend.

As mentioned, the webinar is free to attend, but you'll need to sign up to be able to attend.

tagged: webinar behat testing functional tool behaviordriven development

Link: http://qafoo.com/blog/042_webinar_bdd_behat.html

QaFoo.com:
Behavior Driven Development
Mar 08, 2013 @ 17:54:21

On the QaFoo blog today there's a new post looking at behavior driven development and a PHP-based tool that makes implementing it in your workflow simpler (Behat).

While unit, integration and system tests - especially combined with the methodology of Test Driven Development (TDD) - are great ways to push the technical correctness of an application forward, they miss out one important aspect: the customer. None of these methods verify that developers actually implement what the customer desires. Behavior Driven Development (BDD) can help to bridge this gap.

The introduce some of the basic concepts behind behavior driven development and include an example of a Gherkin-formatted test example checking a page to ensure if has the correct content. They briefly define the structure of the test then take it into a Behat context and show how it would be implemented.

Of course, the examples shown above are only very rudimentary, missing e.g. variables and other advanced features. However, they should have explained what BDD is all about: Communication
tagged: behaviordriven development behat introduction rationale

Link:

Project:
Major Codeception Update (BDD in PHP)
Aug 08, 2012 @ 16:09:11

The Codeception project (BDD testing in PHP) has gotten a major update to its feature set and has bumped up to v1.1:

Many core classes were refactored to solve the common issues and reduce the level of dark magic inside. Only white magic left. And that's really cool 'cause you don't need to study to source code to implement your custom hooks now. Codeception is rapidly evolving to be the professional testing tool, ready to use by testsers and developers through out the PHP world.

Improvements in this large update include an update to the method of test execution, "grabbers" (helper methods that can extract content from tests), the introduction of XPath support to locate items in the content pulled into the test and the integration with unit testing. Upgrade instructions are also included.

tagged: bdd behaviordriven codeception update

Link:


Trending Topics: