Tesults makes libraries available to integrate for various languages which includes −
There is also a REST API available. To upload test generated data and files, one of the libraries must be used.
For some test frameworks, it is possible to integrate without any code using test framework specific libraries that are available.
Test frameworks requiring no code to integrate include −
The integration process is similar for all of these libraries.
Within your test project, install the relevant Tesults plugin. For example, if you are using pytest, this is done using ‘pip install tesults’ followed by ‘pip install pytest-tesults’. If you are using Mocha, you use ‘npm install mocha-tesults-reporter – save’. See the appropriate command for your test framework on the Tesults website.
Some plugins require no configuration and are ready to use immediately, some require a small amount of configuration. In the case of pytest, for example, no additional configuration is required and it is ready to use.
In the case of Mocha, a small change is needed to the ‘mocha’ call, specifically the reporter needs to be specified, ‘mocha --reporter mocha-tesults-reporter’. See the Tesults website for specific configuration for the framework you are using but, in general, the configuration is a one-line change or no change.
There is a required argument to pass to the plugin and other optional arguments. The required arg is to provide the Tesults target token. This token was generated on project creation for the default target in the previous tutorial page. You can get a new token if you do not have this token from the configuration menu in Tesults. Click ‘Regenerate Target Token’ in the configuration menu.
How to pass the argument depends on your test framework and plugin. For example, in pytest it can be provided in the pytest call ‘pytest --tesults-target token_value’ or by using a configuration file. For Mocha, it is similar, it can be passed through in the mocha called ‘mocha * --reporter mocha-tesults-reporter -- tesults-target=token’ or it can be passed in a configuration file.
The target token is the only required arg, there are optional args for passing in build information and for files upload. See the Tesults website for specific information on args for your test framework.
Run your tests and results will now be submitted to Tesults.
If you are using a custom test framework or a test framework for which Tesults does not have a specific library or plugin you need to make use of one of the language frameworks.
Here, we will take a look at what is involved in integrating for Python. Other languages have very similar integration processes, see the Tesults website for specific details for your programming language but follow this tutorial first to get an idea of the process −
For Python, the following is the command −
pip install tesults
For other languages, the process is similar, for JS test frameworks, you install the library from npm, for Java you can use Gradle or Maven, for C# the packages are hosted on NuGet, and Ruby has it available as a gem.
For Python, configuration involves just a require ‘tesults’ in any module you want to use the library. Again, similar configuration is needed in other languages. See the Tesults website for the specific configuration for your programming language.
This step is something that the no code plugins allow you to avoid. For the code based integration you must map your test data to Tesults test data.
For Python, this means turning each test case result into a Python dictionary −
{ 'name': 'Tutorial 1', 'desc':'Tutorial 1 .', 'suite': 'Howcodex', 'result': 'fail', 'reason': 'Assert fail in line 102, howcodex.py', 'files': ['full-path/log.txt', 'full-path/screencapture.png'], '_CustomField': 'Custom field value' }
The name and result are required. Everything else is optional. The result must be one of ‘pass’, ‘fail’, or ‘unknown’.
The suite is useful to provide because it helps groups test cases when viewing results and helps avoid name conflicts. The reason should be provided for failing test cases.
Files are useful for ensuring logs and other test files are stored and can be viewed alongside the test case for which they are for.
You can also have any number of custom fields; they must begin with the underscore (_) character. For each test case, build up a dictionary in this way, and store them in an array.
To upload results, each library provides a results upload function. In the case of Python, you need to call the following −
tesults.results(data)
where the data parameter is follows −
data = { ‘target’: ‘token’, ‘results’: { ‘cases’: [<your test cases>] } }
The cases array is the array created in the section above.
For other programming languages, the process is exactly the same with just syntax changes.
The Tesults website has a way to request help for integration if you need it.
At this point, integration is complete and we can look at how to view, analyse and take action from test results.