What is Behavior Driven Development?

 

Behavior Driven Development [BDD] is an advanced technique used to build software. By the time you reach the bottom of the page, you’ll understand the basics!

System Architecting

Why did the chicken cross the road? To get to the other side!

When designing a system, BDD focuses on the behaviors of the various components, and the values those behaviors create. We work from the outside in, starting with broad strokes and then drilling down into the details.

Chicken “Road Crossing” System
 

System Actor

For each feature of the system, the primary actor must be identified. Who or what is doing something?

  • the user
  • the system
  • a customer
  • the plugin
  • a link
  • a chicken
The Chicken
The Chicken does something.
 

The “Should” Sentence

We first create a should sentence that describes the behavior of the system actor.

The chicken SHOULD cross the road.
 

The Reason Why

Explain the business value of the behavior.

So that it can get to the other side.
 

The Failing Test

Once we know what SHOULD be happening – but isn’t yet – we can make a failing test. The failing test, indicates something that needs to happen, but isn’t happening now. It’s the thing that needs to be developed. If the test passes, that would prove the system works the way we think it should. By creating the failing test first, we indicate the thing that is missing in the world: the thing you and the developer are trying to create.

TEST: Is the chicken crossing the road?
No. The chicken is FAILING to cross the road at this time.

Test examples:

  • Is the ladder strong enough?
  • Do we have enough inventory?
  • Is there money left in the account?
  • Can this feature handle this certain capacity?

function theChickenShouldCrossTheRoad(){
    if (made_it_to_the_other_side()){
      then return "PASS";
    }else{
      then return "FAIL";
    }
}
 

Automation

We use a machine to automate testing our feature. A failing test tells us that the feature isn’t ready yet. This is the Codeception WordPress testing suite. It launches a browser, and tests the behavior of the system like a human would. This is software, BEHAVING like a user [or a chicken].

A failing Codeception test
A failing Codeception test

 

WordPress Plugin Development with Tests = 90% CHEAPER!!

Now the programmer knows the “definition of done”. He must make the test pass! This is the key to reducing SLDC costs in WordPress. There are MILLIONS of cheap WordPress developers. All you have to do, is be able to describe “the definition of done”. The RED_FAIL / GREEN_PASS aspect of automated tests transcend cultures and language. With BDD in WordPress, we can finally outsource software development to offshore developers – AND COMMUNICATE EFFECTIVELY WITH THEM!


$Chicken = new Chicken;
$Chicken->crossTheRoad();
 

Passing Test

Now that the code is written properly, the test passes. The developer and the business stakeholder know they are done with this feature.

Codeception Test Suite
Codeception Test Suite

 

Contact John

Let’s go! There is no charge for an initial consultation. I love talking about WordPress software. Contact me!

John Dee
John Dee