Ghanoz’s BDD test suite template in Vows

Hello again,

I’ve been working for a months in a NodeJS application project and started to use the Behaviour Driven Development pratice on that project. The testing tools I’ve was used is Vows. Vows is an asynchronous behaviour driven development for Node. A few days ago I started to write the test suite in Vows. So, I want to share the template I wrote and intended to be use in NodeJS application that using Vows as testing tools. I’d love to hear any feedback from you all. Here it is, the template:

// The-Ghanozs-Vows-test-suite-template.js
var vows = require('vows');
var assert = require('assert');

var testSuite = vows.describe('Describe the test suite here.');

testSuite.addBatch({
  'Scenario: Explain the scenario description here' : {
    'GIVEN some context' : {
      'WHEN I do something' : {
        topic: function () { return something; },
        'THEN this happens' : function (topic) {
          // assert something here
        }
      }
    }
  }
});

 

// The-example-of-using-the-Ghanoz's-Vows-test-suite-template.js
var vows = require('vows');
var assert = require('assert');

var testSuite = vows.describe('Test the behaviour of anonymous function.');

testSuite.addBatch({
  'Scenario: The called anonymous function should return a 42' : {
    'GIVEN I called an anonymous function AND expect the returned value to be a number' : {
      'WHEN call the function' : {
        topic: function () { return 42; },
        'THEN function should return 42 in number type' : function (topic) {
          assert.isNumber(topic);
        }
      }
    }
  }
});

I uploaded the template on my gists too.
Enjoy!

Leave a 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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s