Mock data with Behat

What is mocking for? Mocking allows you to isolate what you are testing, without  dependency on other areas of application development which are no complete. In Behat, You can easily specify mock data using the following format in your scenarios.  Be wary of “over-mocking” or you will end up with too much illusion, and a lot of re-factoring later on!

Given the following users exist:
| userid | username | password | email |
| 10001 | userone | sunshine1 | |
| 10002 | usertwo | sunshine2 | |

The example code below implements the scenario context:-

* @Given /the following people exist:/
public function thePeopleExist(TableNode $table)
$hash = $table->getHash();
foreach ($hash as $row) {
// $row['userid'], $row['username'], $row['password'], $row['email']

Its a big Given ….

BDD is an enjoyable way to develop and test, but introduce business and that pesky client, it can rapidly change into stressful Waterscrum or (the even worse) Scrummerfall.  Transparency is an easy word to throw out there, but who wants it?  No-one wants to hear bad news and show and tells rapidly descend into a perception game, to pander to client expectations of how development process works.  As with any engineering, most are shocked to learn that engineering is very much an incremental learning process, involving regular mistakes and learning exercises.

The average client expectation is still of having a tangible product, and not to be drawn into the more painful side of development process. It’s a two steps forward, one step back style process. And with BDD, even more so, as the business side is defining a lot more than just high level user stories – they are defining expectations on more granular level.  And in natural language.  Why the last point is very valid is that developers inherently have problems visualising the natural language of requirements in terms of code.  When in fact a scenario line could be viewed as a chunk of functional code.

When reviewing user stories, where the eyes should immediately be drawn to are the “Given” statements.  These generally can appear innocuous, but can hide a whole host of requirements upon development and QA.  Usually used to specify location, authentication and test data.  Test data itself can be a hugely underestimated task, and usually the specifications are wrapped up the the Given statements. Also smart to analyse any example tables for assumptions. It may look like innocuous input/output data, but it may be referencing part of a system that are not built yet, or have existing caveats.

BDD gives Agile a sledgehammer edge, and all the better for it – as long as you stay on top of the process, and can manage the client concerns over their over-exposure to the process.


Semantic coffee

Seems to me, that the major use of semantic web will be for sales and marketing.  As illustrated by the constant bleating the of the importance of “Big Data” is largely by self-publicists waxing lyrical over the joy of “understanding” our needs. i.e. to sell us stuff.  Creating complex algorithms to process this data into something meaningful, deserves something better than sales. We need more voices in this area, who are not  self-serving, patronising salesmen, in evangelist clothing.
Continue reading

We love the system when it loves us

The mock surprise and indignation from people, who had long shut their ears to what I call the bleedin’ obvious. That there are others poking around in our data, analysing with tools to pump out results, for variety of objectives. Whether analysis for marketing demographics, sales targeting, or terrorist spotting – we provide enough data publicly, let alone privately, to benefit those with business or national security. One person’s warbling’s on Facebook, may not mean that much, but times it by millions of people, with even more millions of individual pieces of data and with the right algorithms, it can yield useful results. Continue reading

First WordPress plugin

I released my first WordPress plugin today. I have have been trawling through custom code I have coded over years, and found some that are ideal to turn into plugins. The first is a simple on that adds an address field on the post form, and allows user to add a googlemap identifying location, with a customisable widget. Will be adding a proximity search and multiple map marker display in future releases.  Will also be creating a user guide to demontsrate how to create plugins, and how this particular one was made. Continue reading