1 file was added to this release more than 14 days after its initial publication. Inspect the release files before installing.
unitrail
Simple CLI utility to connect your automated tests with TestRail
Abstract
Unitrail is utility, which allows to push results of tests execution to Testrail server. It reads jUnit XML reports, supported by most of the automated testing frameworks, parses results and maps them to cases listed in your Testrail project.
It requires you to create a simple mapping.json file to describe how do you
want to map tests results to cases.
Installation
Requirements
- Python3+
From source code
Checkout sources and run python setup.py install
Using pip
$ pip install unitrail
CLI interface
usage: unitrail [-h] -r REPORTS [REPORTS ...] [-v] [-s SERVER] -u USERNAME -p
PASSWORD -m MAPPING [-t TESTRUN] [-c CA] [-k] [-O] [-C]
[-D DEFINES [DEFINES ...]]
Fill test run in Testrail using xUnit XML report generated by automated tests
optional arguments:
-h, --help show this help message and exit
-r REPORTS [REPORTS ...], --reports REPORTS [REPORTS ...]
xUnit reports to handle
-v, --verbose Make logs verbose
-s SERVER, --server SERVER
Set TestRail server address (default is
http://testrail/index.php?/api/v2/)
-u USERNAME, --username USERNAME
Username to authenticate in TestRail
-p PASSWORD, --password PASSWORD
Password or API key to authenticate in TestRail
-m MAPPING, --mapping MAPPING
JSON file with mapping of the testcases in report to
scenarios in testrail
-t TESTRUN, --testrun TESTRUN
Existing testrun ID, if not exists - new one will be
created
-c CA, --ca CA Path to the root CA for self-signed certificates
-k, --noverify Disable TLS verification (not recommended)
-O, --leaveopen Do not close test run after execution. Defaults to
false
-C, --forceclose Close test run in the end, nevermind of tests
execution results. Defaults to false
-D DEFINES [DEFINES ...], --defines DEFINES [DEFINES ...]
Define mapping parameters in dynamic from commandline
Basic usage
Create a project in Testrail and fill it with sections and cases as you would like to.
Run your tests and generate jUnit XML report. Let's assume it will generate report file /tmp/report.xml
Let's say you have a case in testrail with name 'My first unitrail test'.
Let's also suggest you have a test named 'My first unitrail test' in your automated tests.
In this case we could map test to case directly by name, and we can easily do that with mapping.json file like follows:
{
"project": "1",
"testrun": {
"name": "Test of parser script",
"description": "Create a flexible filler for testrail"
},
"mapping": [
"case2test"
]
}
Here you can see that all we have inside of the mapping is a basic description of testrun we will create and project ID set.
project field of mapping is a project ID - value you see in URL, when navigate to your project in testrail (like this - http://testrail/index.php?/projects/overview/11)
testrun is a basic description of testrun
mapping is a set of rules to map your tests to cases in testrun. By default - only direct match of names (test and case names) counts as a match.
Now we are all set to create a first testrun in testrail, filled from JUNIT report. Let's run:
$ unitrail -u <user> -p <password> -m mapping.json -r /tmp/report.xml
It will go all the way through, generating you a testrun and filling it. If all tests pushed to testrail will be passed - it will close testrun automatically.
If you want to use already created testrun - you can provide it's ID over commandline:
$ unitrail -u <user> -p <password> -m mapping.json -r /tmp/report.xml -t <TESTRUN ID>
Narrowing the focus
Let's say you have a more real life scenario - you have 1000 tests and only 20 of them are automated now.
We could use Type of test to filter them out, or move them to separate section in project, or something else.
All this is done by filters field of mapping file:
....
"filters": {
"section": {
"name": "Component A"
},
"case": {
"type_id": 1
}
},
....
For example this mapping will use only tests from 'Component A' section with type_id 1 to create new testrun.
You can use any section or case fields as a filter parameters. Reference Testrail API docs, to see all available fields.
Optimizing the mapping
There are also cases when several tests refer to the same case. Or some similar tests reference same case.
You can map multiple cases to multiple tests with simple lists of regexps in mapping field:
....
"mapping": [
"case2test",
{
"matcher": "any",
"case": "Successfull download .*",
"tests": [".*download.*", ".*get data.*"]
},
]
....
Or in a different way - you can match one or several tests to one or several cases
....
"mapping": [
"case2test",
{
"matcher": "any",
"case": [ "Download with europe proxy", "Download with american proxy", "Download with asia proxy"],
"tests": [".*download with .* proxy"]
},
]
....
case2test is a basic matcher for direct match of case and test name.
Dynamic configuration
There is a case when you would like to take all the cases from project and map them directly to tests results.
In this case you can use a basic predefined mapping (show below), but you still want to set project id and testrun description and name dynamically.
In this case you can use -D flag to define any mapping field from commandline.
For example this mapping
{
"filters": {
"case": {
"type_id": 1
}
}
"mapping": [
"case2test"
]
}
can be used to create a testrun for project with ID 666 using this commandline:
$ unitrail -u <user> -p <password> -m mapping.json -r /tmp/report.xml -Dproject=666
-Dtestrun.name="CLI defined testrun name"
-Dtestrun.description="Description from CLI with $VARIABLE"
Metadata
Release files for unitrail 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
File added late
1 file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release files before installing.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| unitrail-0.1.0.tar.gz | 11.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| unitrail-0.1.0-py3.7.egg | Legacy Egg format | - | - | Details |
Total release size: 33.0 kB
Release files / unitrail-0.1.0.tar.gz
| Download URL | unitrail-0.1.0.tar.gz |
|---|---|
| Size | 11.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c590f12b6f417d3c57129922bf3dbc5368fec7d16fd25801a54e654d3df003eb
|
|
BLAKE2b-256 checksum How to use checksums |
e7ba1d1edaa01bd6d1b7423f5e1d0be98f83c33c7cec77da6a1d3858dc55cb32
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.4.2 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.2
|
Release files / unitrail-0.1.0-py3.7.egg
File added late
This file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release file before installing.
| Download URL | unitrail-0.1.0-py3.7.egg |
|---|---|
| Size | 21.6 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
84ba88ce46037099abb07a47b226f3200c7bc09419cdccc249d66e945badb42c
|
|
BLAKE2b-256 checksum How to use checksums |
6da229fb6afef2df45a5c2552411df15625f7ae994266431be85e39c076678ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.4.2 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.2
|
Security for unitrail 0.1.0
Upload timing
File added late
1 file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.