tr-tooling
v0.1.8
Published
This project consists of two components which might help to ease the usage of the TestRail (API)
Downloads
20
Readme
TestRail tools
Motivation
This project consists of two components which might help to ease the usage of the TestRail (API)
- API Wrapper: high level access to the REST API of TestRail
- tr-report: a command line to to upload test results
Installation
Depending on your needs you might want to install this package in two ways:
- globally: you want to use the
tr-report
command line tool - locally: you want to create a custom tool on your own and need a high level API for accessing TestRail
API wrapper
The native API of TestRail is a HTTP based REST-like API. There exists a wrapper package on npm which eliminates the need to directly access the API using a HTTP client. This wrapper still requires tracking of object IDs, though.
Therefore a higher level API had been created on top of the HTTP wrapper to further simplify the usage of the TestRail API for node.js:
TestRail.Project.findByName('Sandbox').then((project) => {
return project.getTestSuites();
}).then((suites) => {
return suites[0].getTestCases();
}).then((testCases) => {
_.each(testCases, (testCase) => {
console.log(testCase.getId(), '=>', testCase.getTitle());
});
}).catch((err) => {
console.log('Nope', err);
});
There is no detailed documentation to the API wrapper available so far. In case you want to
implement custom tools using the wrapper please refer to the examples folder or the tr-report
tool in the bin
directory
Command line tool - tr-report
The package comes with a command line tool named tr-report
which can be used to upload
test results based on a (mocha json report alike) input file.
$ tr-report --help
tr-report <command> [options]
Commands:
run Create a new test run, attach all test results where a test case can be
found and close it
Options:
--help Show help [boolean]
Not enough non-option arguments: got 0, need at least 1
$ tr-report run --help
tr-report run
Options:
--help Show help [boolean]
--host, -h TestRail host URL [required]
--user, -u TestRail user name [required]
--password, -p TestRail password [required]
--project, -n TestRail project name [required]
--suite, -s TestRail suite name [required]
--plan, -l TestRail plan name
--run, -r TestRail run name
--config, -c TestRail config name
--mocha, -m Mocha test report file name [required]
This tool relies on the availability of TestRail test case IDs given in the test result description.
describe('A toaster', function() {
it('should provide a timer (tr-39)', function() { // TestRail Case ID 39 w/o prefix 'C'
assert(true);
});
it('should emergency stop after 5 minutes (tr-C48)', function() { // TestRail Case ID 48 w/ prefix 'C'
assert(true);
});
it('should not consume power when off (tr-50) (trcfg-My Config)', function() { // TestRail Config Name 'My Config'
assert(false);
});
});
Above mocha test will lead to a test report which has TestRail tags (tr-[09]+)
attached to the result
which are used to refer to the correct test case elements in TestRail.