Metadata-Version: 2.1
Name: PyTestLog2DB
Version: 0.2.5
Summary: Imports pytest result(s) to TestResultWebApp database
Home-page: https://github.com/test-fullautomation/python-pytestlog2db
Author: Tran Duy Ngoan
Author-email: Ngoan.TranDuy@vn.bosch.com
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development
Requires-Python: >=3.0
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: colorama
Requires-Dist: mysqlclient
Requires-Dist: lxml

PyTestLog2DB
============

Table of Contents
-----------------

-   [Getting Started](#getting-started)
    -   [How to install](#how-to-install)
-   [Usage](#usage)
-   [Example](#example)
-   [Contribution](#contribution)
-   [Sourcecode Documentation](#sourcecode-documentation)
-   [Feedback](#feedback)
-   [About](#about)
    -   [Maintainers](#maintainers)
    -   [Contributors](#contributors)
    -   [License](#license)

Getting Started
---------------

[PyTestLog2DB](https://github.com/test-fullautomation/python-pytestlog2db)
is the tool that helps to import [PyTest](https://docs.pytest.org)
results file(s) (as [JUnit XML](https://llg.cubic.org/docs/junit)
format) to
[TestResultWebApp](https://github.com/test-fullautomation/TestResultWebApp)
Dashboard.

[PyTestLog2DB](https://github.com/test-fullautomation/python-pytestlog2db)
tool is operating system independent and only works with Python 3.

### How to install

[PyTestLog2DB](https://github.com/test-fullautomation/python-pytestlog2db)
is not available on [PyPI](https://pypi.org/) now.

But you can install this package directly from Github repository as
below:

    pip install git+https://github.com/test-fullautomation/python-pytestlog2db.git

Or you can clone sourcecode to your local directory then install this
package with below steps:

    git clone https://github.com/test-fullautomation/python-pytestlog2db.git
    cd python-pytestlog2db
    python setup.py install

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](https://github.com/test-fullautomation/python-pytestlog2db)
requires the [PyTest](https://docs.pytest.org) result file(s) which
contains the test result in [JUnit
XML](https://llg.cubic.org/docs/junit) format and
[TestResultWebApp](https://github.com/test-fullautomation/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 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.

The below command is simple usage with all required arguments to import
[PyTest](https://docs.pytest.org) 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](https://docs.pytest.org) result file in [JUnit
XML](https://llg.cubic.org/docs/junit) format.

So, firstly execute the [PyTest](https://docs.pytest.org) 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](https://docs.pytest.org) to get the generated [JUnit
XML](https://llg.cubic.org/docs/junit) 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](https://github.com/test-fullautomation/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](packagedoc/additional_docs/pictures/Dashboard.png)

Datatable view:

![Datatable view](packagedoc/additional_docs/pictures/Datatable.png)

### 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](https://github.com/test-fullautomation/TestResultWebApp).
>
> So that,
> [PyTestLog2DB](https://github.com/test-fullautomation/python-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](https://github.com/test-fullautomation/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](https://github.com/test-fullautomation/python-pytestlog2db/blob/develop/PyTestLog2DB/PyTestLog2DB.pdf)
> 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](https://github.com/test-fullautomation/python-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](https://github.com/test-fullautomation/python-pytestlog2db/blob/develop/PyTestLog2DB/PyTestLog2DB.pdf).

Feedback
--------

Please feel free to give any feedback to us via

Email to: [Thomas Pollerspöck](mailto:Thomas.Pollerspoeck@de.bosch.com)

Issue tracking: [PyTestLog2DB
Issues](https://github.com/test-fullautomation/python-pytestlog2db/issues)

About
-----

### Maintainers

[Thomas Pollerspöck](mailto:Thomas.Pollerspoeck@de.bosch.com)

[Holger Queckenstedt](mailto:Holger.Queckenstedt@de.bosch.com)

[Tran Duy Ngoan](mailto:Ngoan.TranDuy@vn.bosch.com)

### Contributors

[Nguyen Huynh Tri Cuong](mailto:Cuong.NguyenHuynhTri@vn.bosch.com)

[Mai Dinh Nam Son](mailto:Son.MaiDinhNam@vn.bosch.com)

[Tran Hoang Nguyen](mailto:Nguyen.TranHoang@vn.bosch.com)

### License

Copyright 2020-2022 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](https://img.shields.io/pypi/l/robotframework.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)

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.


