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

Minister of 1 Massive Database



Do you remember various members of the Labour party going on about that “1 massive database” (to quote IT expert John Prescott)? That was going to tie all public data together. In ONE. MASSIVE. DATABASE. The ill-conceived idea that any IT consultant worth his/her salt would have recommended against, but large corporate IT service providers decided to nod vigorously in agreement, then waste millions of tax payers money implementing systems that they must have known, did not have a hope of fulfilling the requirements. At best, a fabulously expensive experiment. When there is money to be made from ignorance, you can bet your life that business will take full advantage. And none more so that on IT projects, especially government initiated ones. At high-level decision positions, competency in the industry you are working in is a given. In goverment, a Sports minister can become a Work and Pensions minister within a day. Polictians are simply the voice of a department and advisors. Whoever bandied about the phrase “one massive database” to an extent whereby politicans who probably struggled with email, became database champions.

The concept of a single store seems logical enough as a concept, but technologically and architecturally difficult. Plus centralisation of data is a big deal – as whoever is responsible for the centralisation has more control than is necessary or desired. The general feeling is anti-centralisation – so the natural alternative is to think about data in different way, and increase it’s portability. Data that resides in one system can be easily read and manipulated by other systems. Here we go again, into the semantic web territory, where all data in perfectly microformated, with multiple cloud web/data services to process and distribute in a myriad of different ways. This is where philosophy is so right and so wrong – you cannot forget the unpredictability and individualism of human beings, who will do things different to be … well, just different.

Maybe the next government phrase could be “1 massive cloud”, which is of course a complete contradiction. They have interest in Cloud Computing, as data stored in this way transcends many international privact laws. Makes the current phone-tapping scandal seem a little small. Invasion of privacy is about to take a huge leap forward.

Remove empty lines from code

One of the more annoying tidy-up jobs is additional linespaces which few editors support, so I gladly found this javascript snippet which does exactly that. And nothing else – there are online tools that claim to do complete tidy, but from experience, it appears to approach these code tidy exercises seperately.

Simply enter text below to see. A good example of why I needed this was I copied the html from my Linkedin profile, only to be presented by what seemed like 100’s of superfluous empty lines.

This online tool will remove/delete all empty/blank lines/rows within your text/list.  NOTE: Javascript must be enabled.
Continue reading

Hunt the Postbox

Free Our Data

Free Our Data

Do you know where your postboxes are?

Wonderful!  The Post Office are obstructing our information on where Postboxes are, by refusing to list their locations – their techniques at delivering bad service has reached level of an actual recognisable business approach.  And in keeping with turning Post Offices into some kind of Orwellian human cesspit. I always feel I am travelling to different parallel dimension.  The banks are always following the “confuse the customer” appraoch, newer confusing layouts which give appearance of futuristic banking, without provising anyone who can help you beyond taking money out and putting money in.  In the words of Roy from the IT Crowd, “What a bunch of b*stards!”.