CLI for autotests connection with Testrail
Project description
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
TODO
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"
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file unitrail-0.0.1.tar.gz
.
File metadata
- Download URL: unitrail-0.0.1.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d454d23b107d6f47331f4844d22084959dbfe2e2308798ab64e7cf8eed40e67 |
|
MD5 | 7126e27b147f3f1c717b58bde89ce5c9 |
|
BLAKE2b-256 | c7b72cb9e0b1aaae5c2eb052ecb364847b30eedcfc33d225d32fb6fbe2ab4bee |
File details
Details for the file unitrail-0.0.1-py3.7.egg
.
File metadata
- Download URL: unitrail-0.0.1-py3.7.egg
- Upload date:
- Size: 20.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c77b47ff02f7a146c52eec751c91a648b4f1972036782083f4be18fd9cf7773 |
|
MD5 | 1eb0cf3ae2a3b1f4368bc061ad4f981b |
|
BLAKE2b-256 | a2d629bf25e8e735aaf1cd01eb30cefff097930b77bf810f8a4ba67ccacebc3f |