Speed up your Behat testing workflow

So I’m really enjoying Behat and BDD so thought I’d share a cool tip which has sped up my writing test workflow using @tags.

When you need to keep re-running one of your tests you can use tags to make sure you’re only running one thing rather than a whole suite or the whole .feature file.

Basically, in the test you’re working on, add a tag @now

Scenario: Student who has requested an Interview can Apply
When I follow "View"
Then so and so

Now run your test like so,

behat --tags now

It will only ever run that tagged test, so you’re not running loads of others and waiting around. Sometimes, it “feels” even faster to run,

behat --tags now -f progress

I know this may seem pretty simple, but I’m learning here and found this really useful.

An intro to using Trello

More and more University staff here are using Trello for sharing ideas and collaborating on projects.

So I’ve made a super quick intro video which I’d like to share on using Trello for Tracking bugs.

WMG IT - Using Trello
WMG IT – Using Trello

Please remember that Trello is a cloud service and we must abode by the University’s Cloud Usage Rules, http://www2.warwick.ac.uk/services/gov/informationsecurity/faqs/purchasingissues/cloud/

Changing the storage path in Laravel 5

So changing the Storage path in Laravel 5 is apparently more difficult than it possibly should be.

Here’s how I solved it with @stauffermatt ‘s tutorial to start but appended to make sure the storage path is stored in Config per. server rather than hardcoded into your Git stored php files.

  1. First follow Matt Stauffer’s tutorial, and add an application override


# File /app/Application
<!--?php namespace App;

class Application extends Illuminate/Foundation/Application
     * Get the path to the storage directory.
     * @return string
    public function storagePath()
        return $this->basePath.'/theNewStorage';

  1. Then change your `bootstrap/app.php to…
$app = new AppApplication(
  1. NOW, my extra bit. Create a config/paths.example.php and add it to git. Then duplicate it as, config/paths.php, add that file to your .gitignore and change the path to the server’s storage path.

return [

    // Url to the server's storage file
        // eg, 'storagePath' => "/var/www/storage",
       'storagePath' => base_path()."/storage",

  1. Alter you app/Application.php file to load in the Config Repo with your new config file
<!--?php namespace App;

use Illuminate/Config/Repository as Config;

class Application extends Illuminate/Foundation/Application
     * Get the path to the storage directory.
     * @return string
    public function storagePath()
        $path = config_path(). '/paths.php';
        $items = include $path;

        $config = new Config($items);

        return $config->get('storagePath');

There. Dunnit.

SQLite and multiple renaming or dropColumn ‘s error in laravel 5.0 aritsan migrate


One of my migration scripts in Laravel 5 has 3 dropColumn requests in and 1 rename column. This all works fine with laravel migrations on MySQL and MariaDB, as you would expect.

However once you try to run those same migrations on a mysqlite / sqlite database you may start seeing errors like so

SQLSTATE[HY000]: General error: 1 no such column: XXX (SQL: CREATE TEMPORARY TABLE

Now following up the issue on Github it is related to this, https://github.com/laravel/framework/issues/2979 but Taylor doesn’t believe it’s a bug, saying,

I would do them in two separate operations.

 The work around unfortunately is to split EACH drop Column and rename into 1 separate migration file each…

Crazy, but tbh. if that’s the worst bug I come across with Laravel 5, I’ll take it.

State of the union (since starting at Warwick Uni)

A small state of the union post so I don’t forget my journey so far…

The largest change is introducing my Agile experience into many aspects of workflow and to many members of staff.

Agile Training
* I have delivered three separate sets of Agile training
* Once for the Project Management Networking Group
* Once for the WMG IT team
* Once for an individual member of staff

I have introduced some better online tools to support the University’s work
* Trello – The whole IT team use it now to track and collaborate on their work
* Quickcast – The use of screen casting to show staff how to use certain material
* Continuous Integration – GitLab’s CI runner Is now provided by the University following me pushing for access
* Google analytics – To prove that students are using more of their own devices which are Apple based, than the university owned Windows machines
* Twitter Bootstrap must be used across all our custom apps. Our custom built apps from externals had custom CSS wrappers, but now use Twitter bootstrap 3.

Methods of working
* A lot of the Moodle work is “Handle turning”, I have floated the idea of an apprentice, which has led to a summer intern coming in (got ahead of myself, summer interns are always here!)
* IT partners – Following the Agile training, the following ideas of roles and responsibilities of a Product Owner leading and ordering tasks in priorities was taken on for our WMG IT partners
* We use an Agile approach to define what work should be done next. “If it went live tomorrow, what would we need?”

Development Bootstrap
* Deployment
* Folder organistion
* Server registration
* Repository Model
* Interfaces
* Behaviour Driven Development testing
* Unit testing

University Wide
* One of my three University wide ideas has gone onto review stage, using rechargeable mics for presenting will save on batteries and reduce support calls

* Biddr – an online reverse auction. I coached Agile to the staff and also built this learning tool in Laravel 4.
* Gradr – an online app to consolidate marks from multiple modules into one simple dashboard. It provides students a single overview and tutors an overall table of their students marks. I coached the staff in Agile and also built this in Laravel 5.

  • More Project management
  • More Laravel 5 and Elastic Search
  • Improving the University’s IT network (of people, not wires)
  • More training, hopefully in leadership (it’s different here to a small self-owned company!)

Being brave enough to change a process

Today we had to change a large process that wasn’t working.

The State.

A web development being built hasn’t got automated tests written for it and requires an office member to go through and MANUALLY test every item. Basically what Behat or DalekJS should be doing…

Anyway, the tests were all written in 1 document. “When I create a module, it should appear in a student’s list”, “When I select 3 modules, it calculates the student’s points correctly”, etc…

My process to solving a process.

Sometimes improving it can feel a bit daunting, however, as you talk through it with the team, record small sticking points and pains, then the you should start to see a bigger picture.
Always remember, you probably just need an evolution not a total revolution.


  1. Remind the team, that they own this process so they will want to find solutions to save themselves time
  2. Talk through the whole process, record EVERY sticking point
  3. Look through the sticking points for the worst offenders
  4. Think of simple ideas to fix them
  5. Repeat 4 until happy :)
  6. Talk it through with all the team
  7. Go!
  8. Re-look at it again soon!

Our Biggest Problems were…

  • Testing document, who has the latest copy and where?
  • TheTesting document is really fiddly for comments
  • TheTesting document doesn’t really handle versions very well
  • It’s difficult to discuss the comments inside theTesting document
  • What should the developer work on next?

Some solutions…

  • Testing document has been moved to a Shared OneDrive for all the project Team.
  • Re-named testing document “Testing Document v1” to “Testing Document”, losing the version number indicated its “alive” state
  • All Passes are still recorded in the Testing document with the word “Pass”
  • All Fails are recorded int he Testing document as “Fail”, but no comment
  • All Fails with comments are created as tickets in a Trello board with the unique test id and a description of the fail
  • All Fails are re-ordered in the list by the Product Owner to show importance
  • A Trello list was created for the Product Owner to rack up no more than 5 tickets which the need the developer to work on next

Excellent Customer Service training

Today I attended some training on Excellent Customer Service provided by the University.

The reason I signed up was because some of the work I’ve taken over here for providing Moodle Gradebook support is not “so hot” right now. It feels like we’re failing on some really basic stuff, which is frustrating to both me and obviusly the staff. Also, by failing on the basics, it knocking effect of WOW things, like custom code of the gradebook.

To be fair, a lot of the stuff I have taken on is going pretty well and the tutors seem very happy with my Project Management and Custom coding. But, I still want to be doing better in the areas I’m presently weakest in, whether they are inherited problems or brand new.

The first things to learn was, “who is my customer?”, Because yes, my work affects the students too, I did wonder if they were my customer. However, nope. My work sits in a chain of support and my direct customer is the staff I deal with on a day to day basis.

Then we used a very useful model and excercise, the Kano Model. It splits and identifies different parts of your service from Basic, Satisfactory and WOW.


It turns out after doing the excercise, I identified loads of basics, but had trouble picking anything above that. Which is becuase, in a few ways the service isn’t even hitting the basics, so there’s no point offering WOWs. The analogy we were given was, “With a hotel, your basics are Bed, Clean room & Toilet. So if none of those basics are met, you wouldn’t be so overly happy with a WOW of champagne on arrival”.

So… to identify some of the basics within my control,

  1. Staff know when Moodle is going down for maintanence
  2. When marks are released, they stay released
  3. Course rollover will happen

So.. to identify some actions to help with those basics,

  1. Maintenance
  • Create a staff list / Sharepoint group for notifications
  • On receipt of Russell’s emails, share with the list

2. Marks released

  • Map the Moodle Show / Hide flow
  • Request a Show / Hide logger from Central
  • Dan Course to take on marks release for the rest of this term
  • Analyse the Service Now calls raised

3. Course rollover

  • Inform staff when this will happen

Why we test… the two other tests I’m forgetting to write

This morning was spent fixing something, which frankly, I should have known better! However, when you’re coding and project managing on your own, it’s not easy to keep everything rolling.

When I write new Repository methods, I leave a comment note @totest to remind me to come back and write some tests!

However, I’ve missed writing 2 simple types of tests which would have taken 20 mins and then saved me an hour this morning. So I thought I’d share with you lot.

In My Laravel Middleware I have a method which checks the UserId provided is one of our students.

    $user = $this->userRepo->findByUidOrFail($this->fetchUser());

However, because I haven’t filled in any tests on that Repo yet, I’ve been going around the houses trying to fix a problem which some simple unit tests would have flagged 2 days ago. The return wasn’t erroring if the user isn’t there AND was returning a Collection when it should have been giving me a Model

So along with unit testing positive results from a successful method call, we should be writing two other types of tests.

The Exception Test.

Clearly this method name says, find…OR FAIL!!!! However, it wasn’t throwing a ModelNotFoundException on failing, it was just returning a Collection!

The tests I have written to assert it’s working now,

// UserRepositoryInterfaceTest.php /** * @expectedException ErrorException */ public function test_findByUidOrFail_incorrect_params() { $records = $this->theRepo->findByUidOrFail(); } /** * @expectedException Illuminate\Database\Eloquent\ModelNotFoundException */ public function test_findByUidOrFail_modelNotFound() { $this->theRepo->findByUidOrFail("foo"); }

The returned type Test.

It seems weird to test you’re getting the write variable type back, however, it’s crucially important. Because what if you expect an integer, 2, and you’re returned a string of “2”. Any triple if’s === would fail and probably throw something else off.

So we test for cast types. In this example, I assert the Model by looking for a certain method’s availability or not.

// UserRepositoryInterfaceTest.php

public function test_findByUidOrFail_is_model()
    $record = $this->helper->createAUser();
    $result = $this->theRepo->findByUidOrFail($record->uid);


// TestHelper.php

public function assertIsModel($obj)
        method_exists($obj, 'getTable'),
        'obj is not a Model'