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:
Unit Testing Succinctly Why Unit Test?
October 16, 2014 @ 12:06:05

NetTuts.com has kicked off a new series of posts today that answers the question "Why unit test?" The series, Unit Testing Succinctly aims to define what unit testing is, approaches to implementing them and what they can do to help you and your application.

The usual mantra we hear regarding any software methodology is that it improves usability and quality, reduces development and testing time, and brings the product to market faster and with fewer bugs. These are lofty goals, but I have yet to see a methodology deliver the Grail of software development. Ultimately, the primary reason to write unit tests is to prove correctness, and this happens only if you write unit tests well.

In this first post they cover three of the more general reasons for making the dive into unit testing your applications at all. These are more "business value" kinds of ideas but they trickle down into the development level, providing value for the developers too.

  • Measuring Correctness
  • Repetition, Repetition, Repetition
  • Code Coverage

Their main point to reinforce is the first of the three, though. Unit testing helps to measure and ensure correctness of both the code itself and the functionality it performs.

0 comments voice your opinion now!
unittest introduction why correctness coverage repeatability

Link: http://code.tutsplus.com/articles/unit-testing-succinctly-why-unit-test--cms-22410

Rami Alnawas:
How to unit test code with Phalcon MVC Models
April 29, 2014 @ 11:57:39

Rami Alnawas has posted an interesting tutorial for the Phalcon users out there showing one way you can unit test your models. It's based on his own experience with the framework in a current project.

My first contribution to the PHP community in general, and Phalcon folks in particular, was the introduction of MVC Functional Testing with PHPUnit, this meant that Applications developed using Phalcon Framework could be unit tested by requesting a url then asserting that the response is handled by a specific action within the controller. [...] To date, my latest addition is an example of how to unit test code that utilises Phalcon models, mainly the various static find methods. The code is available on github and the coverage report is coveralls.io.

He shows it at work, creating a simple "Popup" model and a facade to help with making instances for testing. He also includes the code to test this facade, checking the results of methods like "fetchall", "select" and "execute".

0 comments voice your opinion now!
phalcon framework unit test coverage mvc model tutorial

Link: http://www.rami.me.uk/how-to-unit-test-code-with-phalcon-mvc-models

The PHP.cc Blog:
PHPUnit 4.0 Code Coverage Improvements
March 10, 2014 @ 10:47:41

The latest version of the popular PHP unit testing tool PHPUnit has officially been released (version 4.0.0) and comes with some nice improvements. In this post to the PHPcc blog Sebastian Bergmann talks about enhancements in one area - code coverage reporting.

One of the highlights of PHPUnit 4.0, which was released last week, is an improvement of the @covers annotation and the addition of the @uses annotation for better code coverage analysis.

He includes a few simple code snippets showing you how the "@covers" annotation has been working and how it can be used in both strict and non-strict modes. He also introduces the "@uses" annotation to define which objects the test is using and how the two interact. He finishes off the post with a mention of the "--strict-coverage" command line flag (or the more general "--strict").

0 comments voice your opinion now!
code coverage improvements phpunit unittest

Link: http://thephp.cc/viewpoints/blog/2014/03/phpunit-4-0-code-coverage-improvements

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

Dutch Web Alliance:
The definitive remote debug and unittest with PHPStorm guide part 5
December 24, 2013 @ 13:09:05

The Dutch Web Alliance has posted the fifth part (of seven) of their series looking at configuring the PHPStorm IDE to remotely debug and run your unit tests. In this article they focus in on getting coverage information from the tests and generating the reports.

They walk you through all of the terminology and configuration you'll need to get things working. They include an example of a Closer coverage configuration file (XML) to push the results out where PHPStorm can grab them. They show show the result (screenshot) of the coverage results being shown inside the IDE.

This is part five of the series, so if you'd like to get caught up check out the full table of contents for links to all of the posts so far.

0 comments voice your opinion now!
remote debug unittest code coverage clover report series tutorial

Link: http://dutchweballiance.nl/techblog/the-definitive-remote-debug-and-unittest-with-phpstorm-guide-part-5-2/

QaFoo.com:
Code Coverage with Behat
April 03, 2013 @ 12:37:30

On the QaFoo blog today there's a post for those using the Behat testing tool showing a way to collect code coverage metrics based on your tests using the PHP_CodeCoverage library and phpcov.

There is generally no point in having code coverage for Behat test cases because of their nature: The purpose of an acceptance test is to assert a certain behavior of an application, not to technically test a piece of code. Therefore, there is no point in checking for uncovered code pieces in order to write a Behat test for it. That said, there is still a scenario where you want to peek at code coverage of Behat tests: When creating them as wide-coverage tests before starting to refactor legacy code. Behat in combination with Mink provides you with a great tool for such tests.

They help you get the tools installed and show the code you'll need to add to the application itself to collect the coverage data as the tests execute. It keys off of a file existing/not existing to know if it should execute the coverage or not. The phpcov tool can then be used to generate the HTML output of the coverage information for easy viewing.

0 comments voice your opinion now!
code coverage testing functional behat tutorial phpcov phpcodecoverage

Link: http://qafoo.com/blog/040_code_coverage_with_behat.html

DevHell Podcast:
Episode 3 Beatings Will Continue Until Test Coverage Improves
January 10, 2012 @ 13:58:03

The latest episode of the DevHell podcast has been posted - Episode 3, "Beatings Will Continue Until Test Coverage Improves".

Fresh off our holiday break, we're back with our longest show yet. We talk about Chris' new book The Grumpy Programmer's Guide To Building Testable PHP Applications, including his experiences self-publishing with Leanpub. Chris also explains how he fears no precipitation on his excursions to the Codemash conference in Ohio. Then Ed talks about the thought process that lead to his latest shit-stirring blog post "The MicroPHP Manifesto." Ed may or may not begin crying openly. Finally, we discuss when it might be necessary to trash your existing application and rewrite it.

You can listen to this latest episode either via the in-page player or by downloading the mp3 directly.

0 comments voice your opinion now!
podcast devhell unittest coverage chrishartjes edfinkler


Volker Dusch's Blog:
Textual code coverage information for PHPUnit
November 25, 2011 @ 16:11:41

In a new post to his blog Volker Dusch points out a new feature in a recent release of PHPUnit, the popular unit testing framework for PHP - textual code coverage details.

Three weeks ago PHPUnit 3.6 was released and it has a little new feature you might have missed until now. PHPUnit can now show you code coverage information on the command line.

Options for the report output include: colorizing, writing the output to a file, including a project summary, namespace separation and package (using the @package phpdoc tag) information. He includes a use case he's found for it - small projects where you can cover the whole codebase quickly (with a "watch" command example filtering based on a certain class).

0 comments voice your opinion now!
textual code coverage report phpunit tutorial feature summary


DevShed:
Using Conditional Statements with the Xdebug Extension
March 04, 2009 @ 12:08:43

DevShed continues their series looking at the XDebug extension for PHP with this fifth part looking a bit more at the code coverage functions it comes with.

In this fifth part of a series on using the Xdebug extension to help debug your PHP programs, we'll take a closer look at the xdebug_start_code_coverage() and xdebug_get_code_coverage() functions. Specifically, we'll see how we can extend their usage when working with conditional statements. As always, we'll complement theory with a number of hands-on examples.

They start with a review of the previous tutorial (that started the look at code coverage) and continue on to show how to extend a code coverage class to debug some conditionals and return the results in a simple echoed output.

0 comments voice your opinion now!
conditional statement xdebug tutorial coverage


PHP.net:
TestFest 2008 wrap-up
July 31, 2008 @ 09:32:45

PHP.net has posted a wrapup of this year's TestFest and the great progress that was made to bring the language development up to the next level.

Overall 158 tests have been submitted as part of TestFest 2008 since the launch of the TestFest submission site by 30 different people from people all over the world. Actually this is not counting the various submissions by existing core developers, who also took this opportunity to add some more tests. This has actually increased total test coverage by about 10%.

It also mentions Felix De Vliegher who, because of his large volume of tests (and quality of them), was granted commit rights into the PHP repository to add his in himself. The list of elePHPant winners is included as well. You can also still submit tests through the TestFest submission site (just not for any of the rewards).

0 comments voice your opinion now!
testfest2008 wrapup test coverage phpt elephpant



Community Events





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


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

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