BDD > TDD – Site Infrastructure Test v4

Back towards the end of April, a test manager at one of my clients listened to me talk about the test framework I had built over the last couple of years. He was supportive and eager to run tests.

He also very casually asked me why I hadn’t considered “Behaviour-driven development”, BDD, instead of TDD. I had no answer, because, frankly, I had never heard of BDD.

At the hotel, later that evening, I spent some time reading about BDD and had a pretty extreme “aha!” moment.

There is something sublime about finding a new way of doing things, particularly if that new way is smooth and easy. I spent three days to essentially rebuild the whole framework using cucumber, and the result was quite simply lightyears ahead of my old code.

BDD > TDD

In order to explain why I think BDD blows away TDD for this use case, let me just show you a screenshot of my old test description JSON file, and a feature file in the new version using gherkin syntax.

[screenshot]
Test descriptions – old vs new
While the old JSON syntax does the job, the new one is much more readable. And given that I am asking Analysts or Marketers to write and maintain the tests, that is important.

I think that any non-technical person should be able to write features using gherkin.

Behind the scenes, the cucumber framework now handles all test creation and there is no need anymore for a bespoke test suite generator. Consequently, the size of the code overall has reduced from 2248 to just 512 lines of code.

I have replaced the old stuff in the github repository. There is simply no reason to use clunky, old code if instead you can use much simpler stuff.

Check out the README for syntax tips, specifically for the phrases you have available to write features. Given how simple it is to write those tests with cucumber, I’m open to any ideas!

Have fun testing

And do let me know if you preferred the old framework. I can for the life of me not see why you would, but I’m open to arguments.

7 thoughts on “BDD > TDD – Site Infrastructure Test v4

  1. Hi Jan,

    This is awesome, Thank you! I was introduced to this at Summit several years ago and am trying to update to v4. I have the test suite up and running and am struggling with the target checks.

    Specifically,

    Feature statements
    Then AT is present
    And AT version version is “1.0” or later
    And AT lib type is “at.js
    And AT mbox named “target-global-mbox” exists

    Log results in terminal
    Then AT is present # PageSteps.at_is_present()
    And AT version version is “1.0” or later # null
    And AT lib type is “at.js # null
    And AT mbox named “target-global-mbox” exists # null

    I have a 10 second delay in the test after the page is loaded.

    Are these target check methods still supported in BDD/ v4 ? Are they any additional tips or tricks to get them to work?

    Like

  2. Thank you for the reply. For me, the framework seems to be skipping some statements.

    Specifically:
    Then an Adobe Analytics call has been sent for report suite “xxxx”
    And Adobe Target version is “1.0” or later
    And Adobe Target lib type is “at.js
    And Adobe Target mbox named “target-global-mbox” exists

    The last output from the framework looks like this with a similar messages for each above statement :

    @Then(“an Adobe Analytics call has been sent for report suite {string}”)
    public void an_Adobe_Analytics_call_has_been_sent_for_report_suite(String string) {
    // Write code here that turns the phrase above into concrete actions
    throw new cucumber.api.PendingException();
    }

    @Then(“Adobe Target version version is {string} or later”)
    public void adobe_Target_version_version_is_or_later(String string) {
    // Write code here that turns the phrase above into concrete actions
    throw new cucumber.api.PendingException();
    }

    Any idea what I am doing wrong here ?

    Like

    1. Hi Curtis,

      All those “//Write code here that turns…” messages look as if the version of the framework you are using hasn’t implemented any of the tests at all. That is weird!

      How did you deploy the framework? Using git? Or using the ZIP file?

      HTH,
      Jan

      Like

      1. Thank you. I re-installed using git and updated the version of the chromedriver I was using. The test are all working now.

        Like

Leave a Reply to Jan Exner Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.