Skip to content

Commit

Permalink
seperated rinuts web service from the nodeunit driver. Now this pacak…
Browse files Browse the repository at this point in the history
…ge consists of only the rinuts service which takes in a driver and exposes a RESTful api to display and activate the driver's tests
  • Loading branch information
urigolani committed Oct 18, 2011
1 parent 8454eb8 commit 18e44e7
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 427 deletions.
45 changes: 20 additions & 25 deletions Readme.md
@@ -1,9 +1,9 @@

# rinuts

Exposes nodeunit based tests through a RESTful api, allowing to remotely query for the urls of supported tests and to activate them, receiving a detailed test run summary.
A service which exposes tests through a RESTful api. Allows for remote querying and running tests on the service, by using http requests", as well as retrieving a detailed run information

built on [node](http://nodejs.org) , [nodeunit](http://github.com/caolan/nodeunit) and [express](http://github.com/visionmedia/express)
built on [node](http://nodejs.org) and [express](http://github.com/visionmedia/express)

## Installation

Expand All @@ -16,45 +16,40 @@
### Starting the service:
var path = require('path'),
rinuts = require('rinuts');

rinuts.listen([path.resolve('/tests/testFolder'), path.resolve('../tests/testSuite1.js'), require('../testSuite2')], 9999);
rinuts = require('rinuts'),
someDriver = require('rinuts-someDriver'),
service;
// what ever api the driver has to load tests
someDriver.addTests(*TESTS*);
service = new rinuts(someDriver);
service.listen(3333);

### Service API:
* listen(modules, port)
Loads 'modules' and starts listening for requests on 'port'.
[Argument] port - string specifying the port number to listen on.
[Argument] modules - any of the following : a nodeunit module | a path to nodeunit file |
a path to a directory (includes subdirs) | an array containing any of the previous.
* *ctor* (driver)
Constructor. Loads a driver which implementes 'enumTests' and 'runTest'.
[Argument] driver - The driver

### HTTP exposed API:

* GET /tests : JSON response with a list of the tests exposed. Each test includes it's unique name and a POST URL which can be used to execute it. The list structure is as follows:
{
"*moduleName_testName*": {
"*testName*": {
"name": "*testName*",
"url":"/tests/*moduleName*/*testName*"
"url":"/tests/*testName*"
}
...
}

* GET /tests/:testName : Returns an individual entry from the list above. has the form of:
{
"name": "*testName*",
"url": "/tests/*moduleName*/*testName*"}
"url": "/tests/*testName*"}

* POST /tests/:testName : Executes the individual test and returns the test run summary, including stdout/err capture, in the following structure:
* POST /tests/:testName : Executes the individual test and returns the test run summary, in the following structure (can be expanded by the driver):
{
"name": *testName*,
"duration": *in milliseconds*,
"state": *true|false*,
"assertions": [{
"method": *ok | fail etc...*
"success": *true|false*,
"message": *assertion message*, // included only for failed tests
"stack": *stack trace*, // included only for failed tests
},
...
]
"name": *testName*,
"state": *true|false*
}
34 changes: 34 additions & 0 deletions example/mockRinutsDriver.js
@@ -0,0 +1,34 @@
var driver = function (tests) {
this.init(tests);
};

module.exports = driver;

driver.prototype = {
init: function (tests) {
this.tests = tests;

},
enumTests: function (callback) {
var tests = [],
key;

console.log(this.tests.length);
for (key in this.tests) {
if (this.tests.hasOwnProperty(key)) {
tests.push(this.tests[key].name);
}
}

callback(null, tests);
},
runTest: function (testName, callback, context) {
var test = this.tests[testName],
responseFormat = {
name: testName,
state: test.method()
};

callback(null, responseFormat);
}
};
11 changes: 0 additions & 11 deletions example/testSuite1.js

This file was deleted.

18 changes: 14 additions & 4 deletions example/usageExample.js
@@ -1,8 +1,18 @@
var path = require('path'),
rinuts = require('./../index.js');

//rinuts.listen([path.resolve('testFold'), path.resolve('testSuite1.js')], 9999);
rinuts.listen(require('./testSuite1'), 9999);
rinuts = require('./../index.js'),
driver = require('./mockRinutsDriver.js');

var mockdriver = new driver({
test1: {
name: 'test1',
method: function () {
return true;
}
}
});

var rinutsService = new rinuts(mockdriver);
rinutsService.listen(9999);



Expand Down
215 changes: 0 additions & 215 deletions lib/nodeunitDriver.js

This file was deleted.

0 comments on commit 18e44e7

Please sign in to comment.