behave-reportportal


Namebehave-reportportal JSON
Version 4.0.2 PyPI version JSON
download
home_pagehttps://github.com/reportportal/agent-python-behave
SummaryAgent for reporting Behave results to the ReportPortal
upload_time2023-10-24 08:19:35
maintainer
docs_urlNone
authorReportPortal Team
requires_python>=3.6
licenseApache 2.0
keywords testing reporting reportportal behave
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ===================
agent-python-behave
===================

.. image:: https://img.shields.io/pypi/v/behave-reportportal.svg
    :target: https://pypi.python.org/pypi/behave-reportportal
.. image:: https://img.shields.io/pypi/pyversions/behave-reportportal.svg
    :target: https://pypi.org/project/behave-reportportal
.. image:: https://github.com/reportportal/agent-python-behave/actions/workflows/tests.yml/badge.svg
    :target: https://github.com/reportportal/agent-python-behave
.. image:: https://codecov.io/gh/reportportal/agent-python-behave/branch/master/graph/badge.svg
    :target: https://codecov.io/gh/reportportal/agent-python-behave
.. image:: https://slack.epmrpp.reportportal.io/badge.svg
    :target: https://slack.epmrpp.reportportal.io/
    :alt: Join Slack chat!
.. image:: https://img.shields.io/badge/reportportal-stackoverflow-orange.svg?style=flat
    :target: http://stackoverflow.com/questions/tagged/reportportal
    :alt: stackoverflow

Behave extension for reporting test results of Behave to the Reportal Portal.

* Usage
* Installation
* Configuration
* Launching
* Test item attributes
* Logging
* Test case ID
* Integration with GA
* Copyright Notice

Usage
-----

Installation
~~~~~~~~~~~~

To install agent-python-behave it's necessary to run :code:`pip install behave-reportportal`.

You can find example of integration with behave agent `here <https://github.com/reportportal/agent-python-behave/blob/master/tests/features/environment.py>`_
You can just copy this file to your features folder.


Configuration
~~~~~~~~~~~~~

Prepare the config file :code:`behave.ini` in root directory of tests or specify
any one using behave command line option:

.. code-block:: bash

    behave -D config_file=<path_to_config_file>


The :code:`behave.ini` file should have next mandatory fields under [report_portal] section:

- :code:`api_key` - value could be found in the User Profile section
- :code:`project` - name of project in ReportPortal
- :code:`endpoint` - address of ReportPortal Server

Example of :code:`behave.ini`:

.. code-block:: text

    [report_portal]
    api_key = fb586627-32be-47dd-93c1-678873458a5f
    endpoint = http://192.168.1.10:8080
    project = user_personal
    launch_name = AnyLaunchName
    launch_attributes = Slow Smoke
    launch_description = Smoke test

The following parameters are optional:

- :code:`client_type = SYNC` - Type of the under-the-hood ReportPortal client implementation. Possible values: [SYNC, ASYNC_THREAD, ASYNC_BATCHED].
- :code:`launch_name = AnyLaunchName` - launch name (default value is 'Python Behave Launch')
- :code:`launch_id = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` - id of the existing launch (the session will not handle the lifecycle of the given launch)
- :code:`launch_attributes = Smoke Env:Python3` - list of attributes for launch
- :code:`launch_description = Smoke test` - launch description
- :code:`debug_mode = True` - creates the launch either as debug or default mode (defaults to False)
- :code:`log_layout = Nested` - responsible for Scenario, Step or Nested based logging (Scenario based approach is used by default)
- :code:`is_skipped_an_issue = False` - option to mark skipped tests as not 'To Investigate' items on Server side.
- :code:`retries = 3` - amount of retries for performing REST calls to RP server
- :code:`rerun = True` - marks the launch as the rerun
- :code:`rerun_of = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`` - launch id to rerun
- :code:`launch_uuid_print = True` - Enables printing Launch UUID on test run start. Default `False`.
- :code:`launch_uuid_print_output = stderr` - Launch UUID print output. Default `stdout`. Possible values: [stderr, stdout].
- :code:`connect_timeout = 15` - Connection timeout to ReportPortal server. Default value is "10.0".
- :code:`read_timeout = 15` - Response read timeout for ReportPortal connection. Default value is "10.0".
- :code:`log_batch_size = 20` - maximum number of log entries which will be sent by the agent at once
- :code:`log_batch_payload_size = 65000000` - maximum payload size of a log batch which will be sent by the agent at once

If you like to override the above parameters from command line, or from CI environment based on your build, then pass
- :code:`-D parameter=value` during invocation.


Launching
~~~~~~~~~
To execute tests with ReportPortal you should run `behave` command and specify path to feature files:

.. code-block:: bash

    behave ./tests/features


Test item attributes
~~~~~~~~~~~~~~~~~~~~

Tag `attribute` could be used to specify attributes for features and scenarios.
Attributes should be listed inside brackets of attribute tag separated by commas.

Example:

.. code-block:: python

    @attribute(key:value, value2)
    @attribute(some_other_attribute)
    Feature: feature name

        @attribute(key:value, value2, value3)
        Scenario: scenario name


Logging
~~~~~~~

For logging of the test item flow to ReportPortal, please, use the python
logging handler and logger class provided by extension like bellow:
in environment.py:

.. code-block:: python

    import logging

    from reportportal_client import RPLogger, RPLogHandler

    from behave_reportportal.behave_agent import BehaveAgent, create_rp_service
    from behave_reportportal.config import read_config


    def before_all(context):
        cfg = read_config(context)
        context.rp_client = create_rp_service(cfg)
        context.rp_client.start()
        context.rp_agent = BehaveAgent(cfg, rp_client)
        context.rp_agent.start_launch(context)
        logging.setLoggerClass(RPLogger)
        log = logging.getLogger(__name__)
        log.setLevel("DEBUG")
        rph = RPLogHandler(rp_client=context.rp_client)
        log.addHandler(rph)
        context.log = log

Logger provides ability to attach some file in scope of log message (see examples below).

in steps:

.. code-block:: python

    @given("I want to calculate {number_a:d} and {number_b:d}")
    def calculate_two_numbers(context, number_a, number_b):
        context.number_a = number_a
        context.number_b = number_b
        context.log.info("log message")

        # Message with an attachment.
        import subprocess
        free_memory = subprocess.check_output("free -h".split())
        context.log.info("log message with attachment", attachment={
                "name": "free_memory.txt",
                "data": free_memory,
                "mime": "application/octet-stream",
            })


Test case ID
------------

It's possible to mark some scenario with `test_case_id(<some_id>)` tag. ID specified in brackets will be sent to ReportPortal.

Integration with GA
-------------------
ReportPortal is now supporting integrations with more than 15 test frameworks simultaneously. In order to define the most popular agents and plan the team workload accordingly, we are using Google analytics.

ReportPortal collects information about agent name and its version only. This information is sent to Google analytics on the launch start. Please help us to make our work effective.
If you still want to switch Off Google analytics, please change env variable the way below.

.. code-block:: bash

    export AGENT_NO_ANALYTICS=1


Copyright Notice
----------------
..  Copyright Notice:  https://github.com/reportportal/agent-python-behave#copyright-notice

Licensed under the `Apache 2.0`_ license (see the LICENSE file).

.. _Apache 2.0:  https://www.apache.org/licenses/LICENSE-2.0

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/reportportal/agent-python-behave",
    "name": "behave-reportportal",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "testing,reporting,reportportal,behave",
    "author": "ReportPortal Team",
    "author_email": "support@reportportal.io",
    "download_url": "https://files.pythonhosted.org/packages/fe/fa/a07de0a760aed5891d1ba908e56dba1402036404676af79fd152051ad0af/behave-reportportal-4.0.2.tar.gz",
    "platform": null,
    "description": "===================\nagent-python-behave\n===================\n\n.. image:: https://img.shields.io/pypi/v/behave-reportportal.svg\n    :target: https://pypi.python.org/pypi/behave-reportportal\n.. image:: https://img.shields.io/pypi/pyversions/behave-reportportal.svg\n    :target: https://pypi.org/project/behave-reportportal\n.. image:: https://github.com/reportportal/agent-python-behave/actions/workflows/tests.yml/badge.svg\n    :target: https://github.com/reportportal/agent-python-behave\n.. image:: https://codecov.io/gh/reportportal/agent-python-behave/branch/master/graph/badge.svg\n    :target: https://codecov.io/gh/reportportal/agent-python-behave\n.. image:: https://slack.epmrpp.reportportal.io/badge.svg\n    :target: https://slack.epmrpp.reportportal.io/\n    :alt: Join Slack chat!\n.. image:: https://img.shields.io/badge/reportportal-stackoverflow-orange.svg?style=flat\n    :target: http://stackoverflow.com/questions/tagged/reportportal\n    :alt: stackoverflow\n\nBehave extension for reporting test results of Behave to the Reportal Portal.\n\n* Usage\n* Installation\n* Configuration\n* Launching\n* Test item attributes\n* Logging\n* Test case ID\n* Integration with GA\n* Copyright Notice\n\nUsage\n-----\n\nInstallation\n~~~~~~~~~~~~\n\nTo install agent-python-behave it's necessary to run :code:`pip install behave-reportportal`.\n\nYou can find example of integration with behave agent `here <https://github.com/reportportal/agent-python-behave/blob/master/tests/features/environment.py>`_\nYou can just copy this file to your features folder.\n\n\nConfiguration\n~~~~~~~~~~~~~\n\nPrepare the config file :code:`behave.ini` in root directory of tests or specify\nany one using behave command line option:\n\n.. code-block:: bash\n\n    behave -D config_file=<path_to_config_file>\n\n\nThe :code:`behave.ini` file should have next mandatory fields under [report_portal] section:\n\n- :code:`api_key` - value could be found in the User Profile section\n- :code:`project` - name of project in ReportPortal\n- :code:`endpoint` - address of ReportPortal Server\n\nExample of :code:`behave.ini`:\n\n.. code-block:: text\n\n    [report_portal]\n    api_key = fb586627-32be-47dd-93c1-678873458a5f\n    endpoint = http://192.168.1.10:8080\n    project = user_personal\n    launch_name = AnyLaunchName\n    launch_attributes = Slow Smoke\n    launch_description = Smoke test\n\nThe following parameters are optional:\n\n- :code:`client_type = SYNC` - Type of the under-the-hood ReportPortal client implementation. Possible values: [SYNC, ASYNC_THREAD, ASYNC_BATCHED].\n- :code:`launch_name = AnyLaunchName` - launch name (default value is 'Python Behave Launch')\n- :code:`launch_id = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` - id of the existing launch (the session will not handle the lifecycle of the given launch)\n- :code:`launch_attributes = Smoke Env:Python3` - list of attributes for launch\n- :code:`launch_description = Smoke test` - launch description\n- :code:`debug_mode = True` - creates the launch either as debug or default mode (defaults to False)\n- :code:`log_layout = Nested` - responsible for Scenario, Step or Nested based logging (Scenario based approach is used by default)\n- :code:`is_skipped_an_issue = False` - option to mark skipped tests as not 'To Investigate' items on Server side.\n- :code:`retries = 3` - amount of retries for performing REST calls to RP server\n- :code:`rerun = True` - marks the launch as the rerun\n- :code:`rerun_of = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`` - launch id to rerun\n- :code:`launch_uuid_print = True` - Enables printing Launch UUID on test run start. Default `False`.\n- :code:`launch_uuid_print_output = stderr` - Launch UUID print output. Default `stdout`. Possible values: [stderr, stdout].\n- :code:`connect_timeout = 15` - Connection timeout to ReportPortal server. Default value is \"10.0\".\n- :code:`read_timeout = 15` - Response read timeout for ReportPortal connection. Default value is \"10.0\".\n- :code:`log_batch_size = 20` - maximum number of log entries which will be sent by the agent at once\n- :code:`log_batch_payload_size = 65000000` - maximum payload size of a log batch which will be sent by the agent at once\n\nIf you like to override the above parameters from command line, or from CI environment based on your build, then pass\n- :code:`-D parameter=value` during invocation.\n\n\nLaunching\n~~~~~~~~~\nTo execute tests with ReportPortal you should run `behave` command and specify path to feature files:\n\n.. code-block:: bash\n\n    behave ./tests/features\n\n\nTest item attributes\n~~~~~~~~~~~~~~~~~~~~\n\nTag `attribute` could be used to specify attributes for features and scenarios.\nAttributes should be listed inside brackets of attribute tag separated by commas.\n\nExample:\n\n.. code-block:: python\n\n    @attribute(key:value, value2)\n    @attribute(some_other_attribute)\n    Feature: feature name\n\n        @attribute(key:value, value2, value3)\n        Scenario: scenario name\n\n\nLogging\n~~~~~~~\n\nFor logging of the test item flow to ReportPortal, please, use the python\nlogging handler and logger class provided by extension like bellow:\nin environment.py:\n\n.. code-block:: python\n\n    import logging\n\n    from reportportal_client import RPLogger, RPLogHandler\n\n    from behave_reportportal.behave_agent import BehaveAgent, create_rp_service\n    from behave_reportportal.config import read_config\n\n\n    def before_all(context):\n        cfg = read_config(context)\n        context.rp_client = create_rp_service(cfg)\n        context.rp_client.start()\n        context.rp_agent = BehaveAgent(cfg, rp_client)\n        context.rp_agent.start_launch(context)\n        logging.setLoggerClass(RPLogger)\n        log = logging.getLogger(__name__)\n        log.setLevel(\"DEBUG\")\n        rph = RPLogHandler(rp_client=context.rp_client)\n        log.addHandler(rph)\n        context.log = log\n\nLogger provides ability to attach some file in scope of log message (see examples below).\n\nin steps:\n\n.. code-block:: python\n\n    @given(\"I want to calculate {number_a:d} and {number_b:d}\")\n    def calculate_two_numbers(context, number_a, number_b):\n        context.number_a = number_a\n        context.number_b = number_b\n        context.log.info(\"log message\")\n\n        # Message with an attachment.\n        import subprocess\n        free_memory = subprocess.check_output(\"free -h\".split())\n        context.log.info(\"log message with attachment\", attachment={\n                \"name\": \"free_memory.txt\",\n                \"data\": free_memory,\n                \"mime\": \"application/octet-stream\",\n            })\n\n\nTest case ID\n------------\n\nIt's possible to mark some scenario with `test_case_id(<some_id>)` tag. ID specified in brackets will be sent to ReportPortal.\n\nIntegration with GA\n-------------------\nReportPortal is now supporting integrations with more than 15 test frameworks simultaneously. In order to define the most popular agents and plan the team workload accordingly, we are using Google analytics.\n\nReportPortal collects information about agent name and its version only. This information is sent to Google analytics on the launch start. Please help us to make our work effective.\nIf you still want to switch Off Google analytics, please change env variable the way below.\n\n.. code-block:: bash\n\n    export AGENT_NO_ANALYTICS=1\n\n\nCopyright Notice\n----------------\n..  Copyright Notice:  https://github.com/reportportal/agent-python-behave#copyright-notice\n\nLicensed under the `Apache 2.0`_ license (see the LICENSE file).\n\n.. _Apache 2.0:  https://www.apache.org/licenses/LICENSE-2.0\n",
    "bugtrack_url": null,
    "license": "Apache 2.0",
    "summary": "Agent for reporting Behave results to the ReportPortal",
    "version": "4.0.2",
    "project_urls": {
        "Homepage": "https://github.com/reportportal/agent-python-behave"
    },
    "split_keywords": [
        "testing",
        "reporting",
        "reportportal",
        "behave"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7b2002983aa4801f0f71a03f06c85c9aead9b6a307cc2ac7acde9889929202db",
                "md5": "0e5c748125c54d368e8f845d0e47a46a",
                "sha256": "4f27e217c20734f429bed92e552e2c0b36a343b4eb6f1526c640e90d14b0cf90"
            },
            "downloads": -1,
            "filename": "behave_reportportal-4.0.2-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0e5c748125c54d368e8f845d0e47a46a",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.6",
            "size": 17542,
            "upload_time": "2023-10-24T08:19:33",
            "upload_time_iso_8601": "2023-10-24T08:19:33.456132Z",
            "url": "https://files.pythonhosted.org/packages/7b/20/02983aa4801f0f71a03f06c85c9aead9b6a307cc2ac7acde9889929202db/behave_reportportal-4.0.2-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fefaa07de0a760aed5891d1ba908e56dba1402036404676af79fd152051ad0af",
                "md5": "7b5a558be8b90f8972635343b6fb9956",
                "sha256": "0116fc1a045f8ec62da94c90cadbfdc54738d0ffdcf7168561a63a725a793d1a"
            },
            "downloads": -1,
            "filename": "behave-reportportal-4.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "7b5a558be8b90f8972635343b6fb9956",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 17347,
            "upload_time": "2023-10-24T08:19:35",
            "upload_time_iso_8601": "2023-10-24T08:19:35.033153Z",
            "url": "https://files.pythonhosted.org/packages/fe/fa/a07de0a760aed5891d1ba908e56dba1402036404676af79fd152051ad0af/behave-reportportal-4.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-24 08:19:35",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "reportportal",
    "github_project": "agent-python-behave",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "behave-reportportal"
}
        
Elapsed time: 0.13559s