Skip to main content

Software Development Testing

Too often best practices for testing are an after-thought, or a non-thought with respect to the development and deployment of code.

This generally results in shortcuts or bandaids being applied to the SDLC of an organization which can build up over time and become a major constraint on the future product evolution.

With respect to a PHP driven application, my preference is PHPUnit. So briefly a friendly reminder to distinguish your tests by categorization, without opening up a can-of-worms on how to classify a test; we can do that later.

The simplest and easiest ways to get started with this is to organize your tests within PHPUnit, so you can run specific groups of tests along your deployment cycle.

For example, it’s generally a good practice to run your true unit tests on every commit. If they’re written correctly and concisely this shouldn’t introduce a bottleneck on the developers.

Building on that, this is a simple recommended approach for which tests to run along your pipeline:

  1. Unit
    1. On every commit
    2. After/during each pull-request being merged
  2. Integration
    1. On every preprod build; usually I do this with a jenkins/ansible build in a containerized environment that can hit specific api endpoints.
  3. Functional
    1. On every environment deployment. When deployed to env we’ll run tests specific for that environment to verify behaviors for things like billing rules, email filters, etc.
  4. UI
    1. After deployment; when deployed and “launched” we can run automated UI tests to verify behaviors and UI/UX interactions.
    2. These are typically lower importance/severity, so they can generally happen post-build.

Installing PHP5.6 on Ubuntu 14.04LTS

I recently had to setup PHP 5.6 explicitly for testing and verifying work on a client website. Given Ubuntu 14.04LTS natively supports PHP 5.5.9, and the defacto standard ondrej/ppa is now installing PHP7 it took me a bit to understand exactly how to get 5.6 so we could verify tests and all that goodness. In retrospect, it’s obvious, but this may hopefully save someone out there the hour of raised eyebrows.

Via Ansible:

 

Using Ansible + Vagrant to build a PHP7 LEMP Stack!

I have recently fallen deeply in love with Ansible; thanks largely to my new position at Fresh Consulting. As such I’ve found it incredibly fun to tinker and learn in my spare time and recently decided to tackle PHP7 for a variety of reasons. My pet project CamelotHub was a perfect playground, and I’ve managed to take a playbook from phansible and modify it to build a stable LEMP stack using PHP7, PHP7-FPM, and NGINX 1.9+