Skip to content

Commit

Permalink
Merge pull request #6 from telefonicaid/release/0.5.0
Browse files Browse the repository at this point in the history
Release v0.5.0
  • Loading branch information
Jose Antonio Rodríguez committed Oct 3, 2014
2 parents 77ff468 + 56239ef commit 25d7247
Show file tree
Hide file tree
Showing 10 changed files with 991 additions and 372 deletions.
70 changes: 69 additions & 1 deletion ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,73 @@
# RELEASE NOTES

## v0.5.0 / 3 Oct 2014

### Gherkin framework and reporter

* From now on, Tartare can be invoked as a CLI program, instead of passing in a Tartare reporter to Mocha.
Enter `tartare -h` in a console to see available options.
* A new **tagging and filtering** functionality has been added to Tartare, so features, scenarios and variants can be tagged
and then those tags can be used to filter test execution by using the `--filter` option.
- Tag features and scenarios by calling the `tag` method after its definition: `scenario('myscenario', function() { }).tag('mytag');`
- Tag variants by adding a `tag` property to the dataset object: `dataset = { desc: 'my 1st variant', tag: 'mytag', ... };`
- See `tartare -h` for more info about filtering.
* To use Tartare and the filtering functionality with [Protractor](http://angular.github.io/protractor), use a `mochaOpts` object
such as the following in your `conf.js` file:

```javascript
mochaOpts: {
reporter: ('tartare/gherkin'),
grep: 'tartare: +mytag' // Note that the filter string must be prefixed by 'tartare: '
}
```

* New modifiers have been added to Tartare's keywords (feature, scenario, given, when, and, then) that change their behaviour.
The full set of modifiers is the following:
- `.only`: Restrict the execution to only those features/scenarios having this modifier.
- `.skip`: Make this feature/scenario/step as nonexistent, nor being shown on reports or counted on stats.
- `.manual`: Mark this feature/scenario/step as manual, meaning that the test execution is out of Tartare's scope.
They will be shown with a different style in the report.
Using this modifier is equivalent to not providing a function when defining the feature/scenario/step.
- `.manual.skip`: The same than `.skip` for manual features/scenarios/steps.

Variants can also use those modifiers by adding a field with the modifier name and a truthy value to the variant objects in the dataset array.

Manual features/scenarios/steps will be assigned with a tag named 'manual' so you use it to filter tests execution.

```javascript
scenario.manual('This is a manual scenario', function() {

});

dataset = [
{ manual: true, desc: 'This is a manual variant' }
];
```
* A couple of new methods have been added to features/scenarios in order to make easier bug monitoring:
- `.minorBug(bugId)`: Used for features/scenarios that are somehow buggy but you don't want the report to shown them as buggy.
This method prevents the feature/scenario from being executed (to avoid triggering the bug) and will show the bug id next to the title.
They count as passed in stats.
- `.majorBug(bugId)`: Used for marking features/scenarios as buggy. They are executed showing the bug id next to the title, and are counted as failed in stats.

Variants can also use these features by adding a field with the method name and the bug id as value to the variant objects in the dataset array.

If you provide a parameter named `--bugid-link` to Tartare command line, bug ids will be shown as links using that parameter value
as a template where the string '%s' will be replaced by the bug id. This can be useful to link with some bug tracking system. If no
'%s' placeholder is provided, the bug id will be added to the end of the provided link.

Both methods set a tag named 'bug' so you use it to filter tests execution.

```javascript
scenario('This is a buggy scenario', function() {

}).majorBug('my-bug-id');

dataset = [
{ minorBug: 'my-bug-id', desc: 'This is a variant with a minor bug' }
];
```
## v0.4.0 / 7 Aug 2014

### Gherkin framework and reporter
Expand All @@ -13,7 +81,7 @@
including a better integration with [selenium-webdriver](https://www.npmjs.org/package/selenium-webdriver).

### HTTP helpers and chai plugins
* Fixed a bug that prevented collections module from preserving the HTTP headers name casing.
* Fixed a bug that prevented `collections` module from preserving the HTTP headers name casing.
* Fixed a bug that made `httpAllowHeader` assertion to fail in some corner cases.


Expand Down
168 changes: 168 additions & 0 deletions bin/tartare
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
#!/usr/bin/env node

/*
Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U
This file is part of Tartare.
Tartare is free software: you can redistribute it and/or modify it under the
terms of the Apache License as published by the Apache Software Foundation,
either version 2.0 of the License, or (at your option) any later version.
Tartare is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the Apache License for more details.
You should have received a copy of the Apache License along with Tartare.
If not, see http://www.apache.org/licenses/LICENSE-2.0
For those usages not covered by the Apache License please contact with:
[email protected]
*/

'use strict';

require('../lib/utils');
var fs = require('fs')
, spawn = require('child_process').spawn
;


var supportedReporters = {
'gherkin': 'outputs coloured Gherkin syntax',
'gherkin-md': 'outputs Gherkin syntax in Markdown format'
};

function _printHelp() {
console.log('\n Usage: tartere [options] [files]');
console.log('\n Options:\n');
console.log(' -h, --help output usage information');
console.log(' -V, --version output the version number');
console.log(' -R, --reporter <name> specify the reporter to use [gherkin]');
console.log(' -t, --timeout <ms> set test timeout in milliseconds [10000]');
console.log(' -f, --filter <filter_str> run only tests matching <filter_str>');
console.log(' --reporters display available reporters');
console.log();
console.log(' Filter syntax:');
console.log(' - Tags can only contain uppercase/lowercase letters, numbers, and underscore.');
console.log(' - These tags are reserved: only, skip, manual, bug.');
console.log(' - Tags can be combined with the following operators:');
console.log(' +: before a tag indicates that the tag must exist (it is equivalent to putting the tag alone)');
console.log(' -: before a tag indicates that the tag must NOT exist');
console.log(' & or ,: between two tags (or expressions) means a logic AND');
console.log(' |: between two tags (or expressions) means a logic OR');
console.log(' (): parenthesis can be used to indicate precedence');
console.log();
process.exit(0);
}

function _printVersion() {
console.log(JSON.parse(fs.readFileSync(__dirname + '/../package.json', 'utf8')).version);
process.exit(0);
}

function _printReporters() {
console.log('\n Tartare reporters:\n');
for (var reporter in supportedReporters) {
console.log(' ' + reporter + ' - ' + supportedReporters[reporter]);
}
console.log();
process.exit(0);
}

var opts = {};
var unrecognizedArgs = [];

for (var i = 2; i < process.argv.length; i++) {
switch (process.argv[i]) {
case '-h':
case '--help':
_printHelp();
break;
case '-V':
case '--version':
_printVersion();
break;
case '--reporters':
_printReporters();
break;
case '-R':
case '--reporter':
opts.reporter = process.argv[++i];
if (!supportedReporters[opts.reporter]) {
console.log('\nUnsupported reporter "' + opts.reporter + '". Valid reporters are: ' +
Object.keys(supportedReporters).join(', ') + '\n');
process.exit(-1);
}
break;
case '-t':
case '--timeout':
opts.timeout = process.argv[++i];
break;
case '-f':
case '--filter':
opts.filter = process.argv[++i];
if (!/^[A-Za-z0-9_ ,\-\+&\|\(\)]+$/.test(opts.filter)) {
console.log('\nInvalid filter parameter "' + opts.filter + '". See tartare -h for more info.\n' );
process.exit(-1);
}
break;
case '-g':
case '--grep':
opts.grep = process.argv[++i];
break;
case '-i':
case '--invert':
opts.invert = true;
break;
case '--interfaces':
// Discard this argument to avoid being passed in to Mocha
break;
case '-u':
case '--ui':
// Discard this argument to avoid being passed in to Mocha
// If the argument has a value, discard it too
if (!process.argv[i + 1].startsWith('-')) {
i++;
}
break;
default:
unrecognizedArgs.push(process.argv[i]);
}
}

opts.reporter = opts.reporter || 'gherkin';
opts.timeout = opts.timeout || '10000';


/*
Call Mocha passing needed arguments
*/

var args = [ __dirname + '/../node_modules/mocha/bin/mocha' ];
args = args.concat('--require', __dirname + '/../lib/mocha-gherkin/mocha-gherkin.js');
args = args.concat('--reporter', __dirname + '/../lib/mocha-gherkin/reporters/' + opts.reporter);
args = args.concat('--ui', 'bdd');
args = args.concat('--timeout', opts.timeout);
if (opts.filter) {
// The filter string is convoyed into a RegExp object, due to how Mocha works
args = args.concat('--grep', 'tartare: ' + RegExp.escape(opts.filter));
} else if (opts.grep) {
args = args.concat('--grep', opts.grep);
if (opts.invert) {
args = args.concat('--invert');
}
}
args = args.concat(unrecognizedArgs);

var child = spawn(process.argv[0], args, { stdio: 'inherit' });
child.on('exit', function (code, signal) {
process.on('exit', function() {
if (signal) {
process.kill(process.pid, signal);
} else {
process.exit(code);
}
});
});
6 changes: 6 additions & 0 deletions lib/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ var ApiCollectionsGroup = function ApiCollectionsGroup(config) {
}
}
}
// Remove headers with value null
for (headerName in opt.headers) {
if (opt.headers.hasOwnProperty(headerName) && opt.headers[headerName] === null) {
delete opt.headers[headerName];
}
}

// Set query parameters (if criteria is an object), or append criteria to the uri as a resource identifier
criteria = criteria || '';
Expand Down
Loading

0 comments on commit 25d7247

Please sign in to comment.