node-robotremoteserver
A node.js module providing the robot framework remote library interface.
Installation
Install robot framework first. Then:
$ npm install robotremoteserver
Example
examplelibrary.js:
var fs = require('fs')
var assert = require('assert')
function countItemsInDirectory(path, response) {
fs.readdir(path, function (err, files) {
response(err || files.length)
})
}
countItemsInDirectory.doc = 'Returns the number of items in the directory specified by `path`.'
countItemsInDirectory.args = ['path']
function stringsShouldBeEqual(str1, str2) {
console.log('Comparing \'%s\' to \'%s\'', str1, str2)
assert.equal(str1, str2, 'Given strings are not equal')
}
stringsShouldBeEqual.args = ['str1', 'str2']
exports.count_items_in_directory = countItemsInDirectory
exports.strings_should_be_equal = stringsShouldBeEqual
if (!module.parent) {
var robot = require('../lib/robotremoteserver')
var server = new robot.RobotRemoteServer([exports], { host: 'localhost', port: 8270, allowStop: true })
}
remote_tests.txt:
*** Settings ***
Library Remote http://localhost:${PORT}
*** Variables ***
${HOST} localhost
${PORT} 8270
*** Test Cases ***
Count Items in Directory
${items1} = Count Items In Directory ${CURDIR}
${items2} = Count Items In Directory ${TEMPDIR}
Log ${items1} items in '${CURDIR}' and ${items2} items in '${TEMPDIR}'
Failing Example
Strings Should Be Equal Hello Hello
Strings Should Be Equal not equal
Run the remote server:
$ node examplelibrary.js
The launch tests:
$ pybot remote_tests.txt
License
Released under the MIT license. See the LICENSE file for the complete wording.