News Feed
Sections




News Archive
feed this:

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

NetTuts.com:
A BDD Workflow With Behat and Phpspec
July 04, 2014 @ 14:20:23

NetTuts.com has posted a new tutorial today showing a sample testing BDD workflow using the Behat and PHPSpec testing tools. The BDD (behavior-driven development) approach focuses on using test-driven development and domain-driven design rather than just a unit testing approach.

In this tutorial, we will have a look at two different BDD tools, Behat and phpspec, and see how they can support you in your development process. Learning BDD can be confusing. New methodology, new tools and many questions, such as "what to test?" and "which tools to use?". I hope that this rather simple example will give you ideas to how you can incorporate BDD into your own workflow.

The article isn't a "getting started with BDD" guide, so you'll need to know a bit about the ideas and process before getting into it. He starts with a look at the workflow Taylor Otwell (his inspiration for this) uses and how to install Behat and get to work on a first feature file. He describes the thought process behind the steps and some of the PHP code required to make them work. He then gets to the use of phpspec to mock out a needed "Config" dependency. He works though the rest of the tests and includes the output when all tests are passing.

0 comments voice your opinion now!
bdd workflow phpspec behat taylorotwell tutorial

Link: http://code.tutsplus.com/tutorials/a-bdd-workflow-with-behat-and-phpspec--cms-21601

VG Tech:
Generating Code Coverage of Behat Tests
January 22, 2014 @ 10:52:57

On the VGTech blog today Christer Edvartsen looks at a method of generating the code coverage of Behat tests using a special bit of code and the $_SERVER superglobal to detect what parts of the code is being executed.

Yes, I know, it sounds silly, but bear with me. The nature of acceptance tests is not really to tests units of code, but to assure that the behavior of your application meets a certain set of criteria (Behat Scenarios). When your applications grow over time, code coverage can be a nice tool to help you pinpoint where you need to add more tests. In a perfect world tests are added while implementing new features so that your applications are always fully tested, but that isn't always as easy as it sounds.

The first chunk of code is something that would go in the router of your application, capturing the "collect coverage" and "enable coverage" input variables. The other part of the code creates a unique ID in the set up and uses it in a call (via Guzzle) to the server to start the tracking. In the tear down method, it sends the call to get the coverage results and process them through the PHP_CodeCoverage tool from Sebastian Bergmann.

0 comments voice your opinion now!
code coverage behat test tutorial functional

Link: http://tech.vg.no/2014/01/21/generating-code-coverage-of-behat-tests

NetTuts.com:
BDD With Behat
December 24, 2013 @ 09:14:33

On NetTuts.com they've posted an introductory level tutorial for those that are exploring the world of testing and want to get their feet wet using some other tools. In this new post they introduce Behat, a human-readable functional testing tool written in PHP (but not just for PHP applications).

The BDD PHP framework Behat, allows you to test your PHP applications using human-readable sentences to write features and scenarios about how your applications should behave in order to test out its functionality. We can then run these tests to see if our application is behaving as expected. Let's spend about 15 minutes quickly going over Behat's installation process and learn how we can test our PHP applications behavior using the basics.

They help you get the tool installed (via Composer) and show you how to create your first feature file. They use a simple "adder" class for their examples that has two methods - add and display. The article covers features, scenarios and steps - including the code you'll need to add to the context file for any custom steps. Finally, they show how to run the tests and a sample of what the output looks like when everything's successful.

0 comments voice your opinion now!
bdd behat tutorial introduction beginner

Link: http://net.tutsplus.com/tutorials/php/bdd-with-behat

Chris Hartjes:
The Power of the BrowserProxyMob
November 19, 2013 @ 10:49:38

In this new post to his site Chris Hartjes shares a tool he's found to help with automated front-end testing for web applications - BrowserMobProxy

At work I have been involved with an effort to put some automated front-end testing in place. The combination of Behat, Mink running tests using PhantomJS is a good one for this. Open source, easy to configure, handles JavaScript-heavy pages reasonably well. There was just one wrinkle in our plans: our use of local host files. [...] So clearly what was needed [to solve a hosts file switching issue] was a proxy. After doing a little bit of digging around I found a solution: BrowserMobProxy.

He briefly introduces the tool and helps you get it installed (as well as the library you'll need to interface with the proxy). His library hooks into a running PhantomJS instance and the BrowserMobProxy, generates the right hosts file (not included) and continues on with the tests.

0 comments voice your opinion now!
browserproxymob proxy http request phantonjs unittest behat mink

Link: http://www.littlehart.net/atthekeyboard/2013/11/18/the-power-of-the-browserproxymob/

VG Tech:
Using PHP's Built-in Web Server in Behat Tests
August 19, 2013 @ 10:13:16

On the VG Tech blog there's a recent post showing you how you can use the built-in PHP web server to help with running your Behat (a behavior-driven development tool) tests.

Behat is a tool for running acceptance tests for your application. If your application is a web application you will need a web server to execute your tests. [...] Some weeks back I wrote a post showing you how to use PHP's built in web server in PHPUnit. This post will show you how to do the same for Behat when running your acceptance tests.

His example (here on github) shows you how to set up Behat via Composer, run it and start in on your first test. In the test's "setUp" method, it calls out to the command line and starts up the built-in web server if it's not already running. It also checks to see if it can connect to the server to make sure it's accessible. Then, in the "tearDown" method, there's a call to kill off the PHP process based on the PID stored on startup.

0 comments voice your opinion now!
builtin webserver bdd tests behat setup teardown

Link: http://tech.vg.no/2013/08/16/using-phps-built-in-web-server-in-behat-tests

Francesco Tassi:
Switching From TDD to BDD With Behat and Symfony2
August 16, 2013 @ 13: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.

0 comments voice your opinion now!
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

Codeception.com:
Specification or Testing The Comparison of Behat and Codeception
May 08, 2013 @ 09:28:34

On the Codeception site today there's a new post that compares their tool, Behat and PHPUnit for testing your applications.

This is guest post by Ragazzo. He uses Behat as well as Codeception for making his project better. He was often asked to do a comparison between Codeception, Behat, and PhpUnit. In this post he explains the commons and different parts of this products.

The author talks some about the difference between functional/acceptance tests and how they fit in with behavior driven development. He includes some examples of Behat test formats (Gherkin) and how it can be used for both the functional and acceptance side of things. He also talks some about why he prefers Codeception over Behat(+Mink) for his testing. A sample Codeception test is included, showing a login form check.

0 comments voice your opinion now!
codeception testing behat phpunit acceptance functional comparison

Link: http://codeception.com/05-06-2013/specification-testing-coparison.html

Inviqa techPortal:
Functionally Testing You Application Using Mink
May 02, 2013 @ 13:50:44

On the Inviqa TechPortal today there'a a new post from Konstantin Kudryashov showing you how to use Mink for functional testing (an extension of Behat) of you web application.

Automated testing is big news these days. There's hardly a PHP conference happening without a talk on testing automation or derivative methodologies. TDD (Test-Driven Development) and BDD (Behaviour Driven Development) are all around us. So why should you care about all this? [...] The more complex an application becomes, the harder it is to be sure that each new feature or bug fix won't break the system, and that decreases your overall confidence in your work as developer. That's exactly the reason why you need automated testing - to be confident that you're not breaking important parts of an application.

For his examples he uses a simple Silex-based application (found here on github) that just shows a main page and an "add article" page that returns a preview when submitted. He shows how to get Behat/Mink installed and how to bootstrap PHPUnit to allow you to execute your tests. Also included is a sample test that clicks the "Add Article" link, runs a few checks and fills in some data. The form is submitted and the "preview" page is checked for valid results.

0 comments voice your opinion now!
functional testing behat mink phpunit tutorial

Link: http://techportal.inviqa.com/2013/05/02/functionally-testing-your-application-using-mink

QaFoo.com:
Webinar Behavior Driven Development with Behat
April 17, 2013 @ 10: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.

0 comments voice your opinion now!
webinar behat testing functional tool behaviordriven development

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

Dzone.com:
Diving into Behat
April 09, 2013 @ 09:50:34

Giorgio Sironi has a new post to DZone.com today about some of his experiences with Behat, a behavior-driven development testing tool written in PHP. It uses the Gherkin language syntax to define its tests.

I had the occasion to try out and adopt Behat for a particular need in our projects at Onebip. Here is my recount of the experience from a PHPUnit contributor and invested person.

He starts off with a list of situations where he doesn't think that Behat is a good fit for testing including testing of a single object and acceptance tests where comparing the response from more than one test is needed. He suggests that it's more useful for verifying high level business rules than anything. He talks some about the shift they made to using Behat and some of the benefits they found in its use. He finishes up the post by looking at the technical side and includes a warning about letting the size of the FeatureContext file get too large.

0 comments voice your opinion now!
behat introduction context technical impact overview benefits

Link: http://css.dzone.com/articles/diving-behat


Community Events





Don't see your event here?
Let us know!


list podcast library framework tips bugfix install package laravel language opinion deployment release voicesoftheelephpant api symfony series introduction community interview

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework