Skip to main content

Table of Contents

Getting Started

PyTestLog2DB is a command-line tool that enables you to import pytest XML result files into TestResultWebApp’s database for presenting an overview about the whole test execution and detail of each test result.

PyTestLog2DB tool is operating system independent and only works with Python 3.

How to install

PyTestLog2DB can be installed in two different ways.

The PyTestLog2DB can be installed in two different ways.

  1. Installation via PyPi (recommended for users)

    pip install PyTestLog2DB

    PyTestLog2DB in PyPi

  2. Installation via GitHub (recommended for developers)

    • Clone the python-pytestlog2db repository to your machine.

      git clone https://github.com/test-fullautomation/python-pytestlog2db.git

      PyTestLog2DB in GitHub

    • Use the following command to install PyTestLog2DB (executed in repository main folder):

      python -m pip install .

      Or:

      python -m pip install --proxy <proxy> .

      This command will also download and install all dependencies that are required to work with the source files in the current repository. After the initial installation of PyTestLog2DB is done, you have the following two possibilities:

      1. Clean the previous installation:

        python "./cleanup_installation.py"

        cleanup_installation.py explicitly deletes all files and folders within the component installation folder under site-packages and also deletes local build artefacts.

      2. Render the component documentation:

        python "./genpackagedoc.py"

        This would e.g. be required in case of changes in the interface of PyTestLog2DB.

        The documentation is rendered by a separate application called GenPackageDoc, that is part of the build dependencies and runtime dependencies of PyTestLog2DB.

        GenPackageDoc needs to be configured. Details about how to do this, can be found in the README.rst (sections Install dependencies and Configure dependencies).

    • Use the following command to build PyTestLog2DB (executed in repository main folder):

      python -m build .

      Or:

      python -m pip config set global.proxy <proxy>
      python -m build .

After succesful installation, the executable file PyTestLog2DB will be available (under Scripts folder of Python on Windows and ~/.local/bin/ folder on Linux).

In case above location is added to PATH environment variable then you can run it directly as operation system’s command.

Usage

PyTestLog2DB requires the pytest result file(s) which contains the test result in JUnit XML format and TestResultWebApp’s database information for importing.

Use below command to get tools’s usage

PyTestLog2DB -h

The usage should be showed as below:

usage: PyTestLog2DB (PyTestXMLReport to TestResultWebApp importer) [-h] [-v] [--recursive] [--dryrun] [--append] [--UUID UUID] [--variant VARIANT] [--versions VERSIONS] [--config CONFIG]
                                                                   resultxmlfile server user password database

PyTestLog2DB imports pytest JUnit XML report file(s)generated by pytest into a WebApp database.

positional arguments:
resultxmlfile        absolute or relative path to the pytest JUnit XML report file or directory of report files to be imported.
server               server which hosts the database (IP or URL).
user                 user for database login.
password             password for database login.
database             database schema for database login.

optional arguments:
-h, --help           show this help message and exit
-v, --version        version of the PyTestLog2DB importer.
--recursive          if set, then the path is searched recursively for output files to be imported.
--dryrun             if set, then verify all input arguments (includes DB connection) and show what would be done.
--append             is used in combination with --UUID <UUID>. If set, allow to append new result(s) to existing execution result UUID in --UUID argument.
--UUID UUID          UUID used to identify the import and version ID on webapp. If not provided PyTestLog2DB will generate an UUID for the whole import.
--variant VARIANT    variant name to be set for this import.
--versions VERSIONS  metadata: Versions (Software;Hardware;Test) to be set for this import (semicolon separated).
--config CONFIG      configuration json file for component mapping information.
--interface {db,rest}
                     database access interface.
--testrunurl TESTRUNURL
                     link to test execution job: Jenkins job, Gitlab CI/CD pipeline, ...

The below command is simple usage with all required arguments to import pytest results into TestResultWebApp’s database:

PyTestLog2DB <resultxmlfile> <server> <user> <password> <database>

Besides the executable file, you can also run tool as a Python module

python -m PyTestLog2DB <resultxmlfile> <server> <user> <password> <database>

Example

In order the import the robot result(s) to TestResultWebApp’s database, we need the pytest result file in JUnit XML format.

So, firstly execute the pytest testcase(s) to get the result file(s). But the *.xml result file is not generated by default.

We need to specify the argument –junit-xml=<path> when executing pytest to get the generated JUnit XML report file at given path.

E.g:

pytest --junit-xml=path/to/result.xml pytest/folder

After that, the *.xml result file will be available at path/to/result.xml and can be used for importing to TestResultWebApp with command:

PyTestLog2DB path/to/result.xml localhost test_user test_pw test_db

Then, open TestResultWebApp with your favourite browser and you will see how wonderful the execution result is displayed as below figures:

Dashboard view:

Dashboard view

Datatable view:

Datatable view

Notes:

The *.xml report file generated by pytest contains only the testcase result(s) and less metadata information about the test execution such as project/variant, software version, tester , component, … which are required by TestResultWebApp.

So that, PyTestLog2DB will handle those information with the default values.

But you can use the optional argument –config CONFIG to specify those information when importing to TestResultWebApp’s database.

Sample configuration file:

{
   "variant"   : "MyProject",
   "version_sw": "0.1.1",
   "components": {
      "Testsuite1"       : "test-data.test_tsclass.TestSuite1",
      "Testsuite2"       : "test-data.test_tsclass.TestSuite2",
      "Others"          : [
         "test-data.test_ts1",
         "test-data.test_ts2"
      ]
   },
   "tester"    : "Tran Duy Ngoan"
}

Please refer PyTestLog2DB tool’s Documentation for more detail about default values and the configuration json file.

Contribution

We are always searching support and you are cordially invited to help to improve PyTestLog2DB tool.

Sourcecode Documentation

To understand more detail about the tool’s features, parameters and how pytest result(s) will be displayed on TestResultWebApp, please refer to PyTestLog2DB tool’s Documentation.

Feedback

Please feel free to give any feedback to us via

Email to: Thomas Pollerspöck

Issue tracking: PyTestLog2DB Issues

About

Maintainers

Thomas Pollerspöck

Holger Queckenstedt

Tran Duy Ngoan

Contributors

Nguyen Huynh Tri Cuong

Mai Dinh Nam Son

Tran Hoang Nguyen

License

Copyright 2020-2023 Robert Bosch GmbH

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

License: Apache v2

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytestlog2db-0.4.2.tar.gz (492.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytestlog2db-0.4.2-py3-none-any.whl (487.2 kB view details)

Uploaded Python 3

File details

Details for the file pytestlog2db-0.4.2.tar.gz.

File metadata

  • Download URL: pytestlog2db-0.4.2.tar.gz
  • Upload date:
  • Size: 492.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pytestlog2db-0.4.2.tar.gz
Algorithm Hash digest
SHA256 02f17bdc25192b5a715c131094ea8c38f2e6f2035847bab075a861879ee73aed
MD5 b802f13a7ccba2f9e79b704df7695148
BLAKE2b-256 1458973412ed517bc72cddb33a6951f3f2bc5815dcb42ef247e08952997a7058

See more details on using hashes here.

File details

Details for the file pytestlog2db-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: pytestlog2db-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 487.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pytestlog2db-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4ec5f84e89af3c0554635162be0b73a6264c4eef0c3cac43676439ec0252e41d
MD5 0f25a67b63b55c48d4cd80fc8ad5ce0c
BLAKE2b-256 80c832f7b4cb353cc6812744dc8543c3657ddfa1cada152ebc21598782024cc7

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.4.2 This release

2 files

0.4.0

2 files

0.3.4

2 files

0.3.1

2 files

0.3.0

2 files

0.2.8

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page