michaelfox + unittesting 48
Behat — BDD for PHP
march 2011 by michaelfox
Behat is a BDD framework for PHP
Behat was inspired by Ruby's Cucumber project and especially its syntax part (Gherkin). It tries to be like Cucumber with input (Feature files) and output (console formatters), but in core, it has been built from the ground on the Symfony2 Components.
Learn Behat in 30 minutes with quick intro guide.
php
tdd
bdd
testing
unittesting
framework
Behat was inspired by Ruby's Cucumber project and especially its syntax part (Gherkin). It tries to be like Cucumber with input (Feature files) and output (console formatters), but in core, it has been built from the ground on the Symfony2 Components.
Learn Behat in 30 minutes with quick intro guide.
march 2011 by michaelfox
In a PHP project, how do you organize and access your helper objects? - Stack Overflow
july 2010 by michaelfox
I would avoid the Singleton approach suggested by Flavius. There are numerous reasons to avoid this approach. It violates good OOP principles. The google testing blog has some good articles on the Singleton and how to avoid it:
http://googletesting.blogspot.com/2008/08/by-miko-hevery-so-you-join-new-project.html http://googletesting.blogspot.com/2008/05/tott-using-dependancy-injection-to.html http://googletesting.blogspot.com/2008/08/where-have-all-singletons-gone.html
Alternatives
1) a service provider
http://java.sun.com/blueprints/corej2eepatterns/Patterns/ServiceLocator.html
2) dependency injection
http://en.wikipedia.org/wiki/Dependency_injection
and a php explanation:
http://components.symfony-project.org/dependency-injection/trunk/book/01-Dependency-Injection
This is a good article about these alternatives:
http://martinfowler.com/articles/injection.html
Implementing dependency injection (DI):
-I believe you should ask what is needed in the constructor for the object to function: new YourObject($dependencyA, $dependencyB);
-You can provide the needed objects (dependencies) manually ($application = new Application(new MessageHandler()). But you can also use a DI framework (the wikipedia page provides links to PHP DI frameworks). Important is that you only pass in what you actually use (call an action on), NOT what you simply pass to other objects because they need it. Here's a recent post from 'uncle Bob' (Robert Martin) discussing manual DI vs using framework.
Some more thoughts on Flavius's solution. I don't want this post to be an anti-post but I think it's important to see why dependency injection is, at least for me, better than globals. Even though it is not a 'true' Singleton implementation, I still think Flavius got it wrong. Global state is bad. Note that such solutions also use difficult to test static methods. I know a lot of people do it, approve it and use it. But reading Misko Heverys blog articles (a google testability expert), rereading it and slowly digesting what he says did alter the way I see design a lot. If you want to be able to test you application you'll need to adopt a different approach to designing your application. When you do test-first programming, you'll have difficulty with things like this: 'next I want to implement logging in this piece of code, let's write a test first that logs a basic message' and then come up with a test that forces you to write and use a global logger that can't be replaced. I am still struggling with all the information I got from that blog and it's not always easy to implement and I have many questions. But there's no way I can go back to what I did before (yes, global state and Singletons (big S)) after I grasped what Misko Hevery was saying :-)
php
testing
bestpractices
design
patterns
unittesting
dependency
injection
singleton
http://googletesting.blogspot.com/2008/08/by-miko-hevery-so-you-join-new-project.html http://googletesting.blogspot.com/2008/05/tott-using-dependancy-injection-to.html http://googletesting.blogspot.com/2008/08/where-have-all-singletons-gone.html
Alternatives
1) a service provider
http://java.sun.com/blueprints/corej2eepatterns/Patterns/ServiceLocator.html
2) dependency injection
http://en.wikipedia.org/wiki/Dependency_injection
and a php explanation:
http://components.symfony-project.org/dependency-injection/trunk/book/01-Dependency-Injection
This is a good article about these alternatives:
http://martinfowler.com/articles/injection.html
Implementing dependency injection (DI):
-I believe you should ask what is needed in the constructor for the object to function: new YourObject($dependencyA, $dependencyB);
-You can provide the needed objects (dependencies) manually ($application = new Application(new MessageHandler()). But you can also use a DI framework (the wikipedia page provides links to PHP DI frameworks). Important is that you only pass in what you actually use (call an action on), NOT what you simply pass to other objects because they need it. Here's a recent post from 'uncle Bob' (Robert Martin) discussing manual DI vs using framework.
Some more thoughts on Flavius's solution. I don't want this post to be an anti-post but I think it's important to see why dependency injection is, at least for me, better than globals. Even though it is not a 'true' Singleton implementation, I still think Flavius got it wrong. Global state is bad. Note that such solutions also use difficult to test static methods. I know a lot of people do it, approve it and use it. But reading Misko Heverys blog articles (a google testability expert), rereading it and slowly digesting what he says did alter the way I see design a lot. If you want to be able to test you application you'll need to adopt a different approach to designing your application. When you do test-first programming, you'll have difficulty with things like this: 'next I want to implement logging in this piece of code, let's write a test first that logs a basic message' and then come up with a test that forces you to write and use a global logger that can't be replaced. I am still struggling with all the information I got from that blog and it's not always easy to implement and I have many questions. But there's no way I can go back to what I did before (yes, global state and Singletons (big S)) after I grasped what Misko Hevery was saying :-)
july 2010 by michaelfox
pascaldevink's Patterns at master - GitHub
april 2010 by michaelfox
Full blown project sampling some design patterns, PHPUnit, Phing and Hudson
phpunit
phing
hudson
project
build
deployment
test
unittesting
continuousintegration
april 2010 by michaelfox
Acceptance Testing of Web Applications with PHP
april 2010 by michaelfox
In this article I introduce the topic of Acceptance Testing (aka Functional Testing), something more PHP programmers should be starting to practice. I'm sure many of us are well aware of Unit Testing and even Integration Testing so where does this third wheel come into play for web applications given our growing obsession with Web 2.0 and AJAX and how does it differ from the former two practices? Below I'll explain this. I will also introduce how to implement Acceptance Testing using the killer combination of PHPUnit and Selenium.
php
phpunit
selenium
testing
unittesting
april 2010 by michaelfox
Contributed User-Extensions - Selenium - OpenQA Wiki
april 2010 by michaelfox
This page intends to be a repository for selenium extensions that may be useful to the community.
debug breakpoint, alert, extra info about failures, GUI Map, selectWindow, selenium-0.7-update, labelText, storeTableContent, locateCookie, locateElementByPartialId, getVal, eval, include, store...Global, storeXpath, verifyXpath, assertXpath, selectFrame, waitForCondition, test flow control, gotoIf, assertNoFailureOnNextAndGoto, updateFeedback, removeCookie, storeGetVars, callWebService, storeNamedCookie, storeHasCookie, waitAndActions, getTableRows, isOneOfPresent, flexTesting, datadriven, httpresource, fillform, assertEquals, assertTextPresetCount, assertNumericCompare, assertMetaRobotTags, reloadAndWaitFor* assertions, assertNamedCookie, assertHasCookie, assertTextPresentXML, inputIsEditable, qooxdooExtension,
selenium
unittesting
testing
debug breakpoint, alert, extra info about failures, GUI Map, selectWindow, selenium-0.7-update, labelText, storeTableContent, locateCookie, locateElementByPartialId, getVal, eval, include, store...Global, storeXpath, verifyXpath, assertXpath, selectFrame, waitForCondition, test flow control, gotoIf, assertNoFailureOnNextAndGoto, updateFeedback, removeCookie, storeGetVars, callWebService, storeNamedCookie, storeHasCookie, waitAndActions, getTableRows, isOneOfPresent, flexTesting, datadriven, httpresource, fillform, assertEquals, assertTextPresetCount, assertNumericCompare, assertMetaRobotTags, reloadAndWaitFor* assertions, assertNamedCookie, assertHasCookie, assertTextPresentXML, inputIsEditable, qooxdooExtension,
april 2010 by michaelfox
Selenium IDE Flow Control
april 2010 by michaelfox
This exension provides goto, gotoIf and while loop functionality in Selenium IDE. Selenium IDE is a plugin for Firefox that automates the testing of web-based applications. There is an excellent flow-controll extension for the Selenium Server and TestRunner components, but it does not work with Selenium IDE (the Firefox plugin) directly. This makes it difficult to develop controlled test cases within Selenium IDE, and there are times when the frame-based TestRunner cannot be used (such as when the website under test employs a frame-buster script).
selenium
unittesting
april 2010 by michaelfox
51 Elliot: Selenium IDE Flow Control - Goto and While Loops
april 2010 by michaelfox
This exension provides goto, gotoIf and while loop functionality in Selenium IDE. Selenium IDE is a plugin for Firefox that automates the testing of web-based applications. There is an excellent flow-controll extension for the Selenium Server and TestRunner components, but it does not work with Selenium IDE (the Firefox plugin) directly. This makes it difficult to develop controlled test cases within Selenium IDE, and there are times when the frame-based TestRunner cannot be used (such as when the website under test employs a frame-buster script).
selenium
unittesting
april 2010 by michaelfox
Getting Started With Core Data, Bindings and NSViewController « carpeaqua by Justin Williams
march 2010 by michaelfox
* Core Data
* Cocoa Bindings
* NSViewController
* Unit testing
* And more!
One of the trends in Mac development in recent years is the prevalence of single window applications such as iPhoto, Aperture and Coda. Single window interfaces can be less complex in terms of user interaction, but it can also lead to a more complex underpinning if you don’t watch yourself where you have a single window controller with everything in it1. Apple has aimed to address this with the NSViewController class, which lets you manage portions of the user interface in their own separate class. If you have done any work on the iPhone it’s similar to UIViewController in many aspects.
cocoa
coredata
objc
tutorial
objective-c
unittesting
nsviewcontroller
bindings
* Cocoa Bindings
* NSViewController
* Unit testing
* And more!
One of the trends in Mac development in recent years is the prevalence of single window applications such as iPhoto, Aperture and Coda. Single window interfaces can be less complex in terms of user interaction, but it can also lead to a more complex underpinning if you don’t watch yourself where you have a single window controller with everything in it1. Apple has aimed to address this with the NSViewController class, which lets you manage portions of the user interface in their own separate class. If you have done any work on the iPhone it’s similar to UIViewController in many aspects.
march 2010 by michaelfox
Use your singletons wisely
march 2010 by michaelfox
The programming community discourages using global data and objects. Still, there are times when an application needs a single instance of a given class and a global point of access to that class. The general solution is the design pattern known as singletons. However, singletons are unnecessarily difficult to test and may make strong assumptions about the applications that will use them. In this article I discuss strategies for avoiding the singleton pattern for that majority of cases where it is not appropriate. I also describe the properties of some classes that are truly singletons.
php
design
patterns
oop
singleton
testing
unittesting
ttd
march 2010 by michaelfox
related tags
accelerators ⊕ agile ⊕ ajax ⊕ automation ⊕ bdd ⊕ beautifier ⊕ beginner ⊕ bestpractices ⊕ bindings ⊕ browser ⊕ build ⊕ building ⊕ buildsystems ⊕ cocoa ⊕ code ⊕ codecoverage ⊕ codeigniter ⊕ codesniffer ⊕ collection ⊕ continuousintegration ⊕ coredata ⊕ cruisecontrol ⊕ database ⊕ dbunit ⊕ debug ⊕ debugging ⊕ dependency ⊕ deployment ⊕ design ⊕ development ⊕ editor ⊕ environment ⊕ example ⊕ firebug ⊕ firefox ⊕ framework ⊕ graph ⊕ http ⊕ hudson ⊕ ide ⊕ ids ⊕ image ⊕ injection ⊕ integration ⊕ integrationtesting ⊕ javascript ⊕ jquery ⊕ json ⊕ jstestdriver ⊕ list ⊕ mock ⊕ node.js ⊕ nodejs ⊕ nsviewcontroller ⊕ objc ⊕ objective-c ⊕ oop ⊕ orm ⊕ patterns ⊕ phing ⊕ php ⊕ phpt ⊕ phptools ⊕ phpundercontrol ⊕ phpunit ⊕ project ⊕ qunit ⊕ rails ⊕ rc ⊕ reference ⊕ remotecontrol ⊕ resources ⊕ rest ⊕ ruby ⊕ screenshot ⊕ security ⊕ selenium ⊕ simpletest ⊕ singleton ⊕ soap ⊕ staging ⊕ stories ⊕ tdd ⊕ test ⊕ testing ⊕ tools ⊕ troubleshooting ⊕ ttd ⊕ tutorial ⊕ unit ⊕ unittest ⊕ unittesting ⊖ utilities ⊕ versioncontrol ⊕ webdev ⊕ webservices ⊕ zombiejs ⊕Copy this bookmark: