Package: behave-reportportal
Behave extension for reporting test results of Behave to the Reportal Portal.UsageInstallationConfigurationLaunchingTest item attributesLoggingTest case IDIntegration with GACopyright NoticeUsageInstallationTo install agent-python-behave it’s necessary to runpip install behave-reportportal.You can find example of integration with behave agenthereYou can just copy this file to your features folder.ConfigurationPrepare the config filebehave.iniin root directory of tests or specify
any one using behave command line option:behave-Dconfig_file=<path_to_config_file>Thebehave.inifile should have next mandatory fields under [report_portal] section:api_key- value could be found in the User Profile sectionproject- name of project in ReportPortalendpoint- address of ReportPortal ServerExample ofbehave.ini:[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 testThe following parameters are optional:client_type = SYNC- Type of the under-the-hood ReportPortal client implementation. Possible values: [SYNC, ASYNC_THREAD, ASYNC_BATCHED].launch_name = AnyLaunchName- launch name (default value is ‘Python Behave Launch’)launch_id = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx- id of the existing launch (the session will not handle the lifecycle of the given launch)launch_attributes = Smoke Env:Python3- list of attributes for launchlaunch_description = Smoke test- launch descriptiondebug_mode = True- creates the launch either as debug or default mode (defaults to False)log_layout = Nested- responsible for Scenario, Step or Nested based logging (Scenario based approach is used by default)is_skipped_an_issue = False- option to mark skipped tests as not ‘To Investigate’ items on Server side.retries = 3- amount of retries for performing REST calls to RP serverrerun = True- marks the launch as the rerunrerun_of = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`- launch id to rerunlaunch_uuid_print = True- Enables printing Launch UUID on test run start. DefaultFalse.launch_uuid_print_output = stderr- Launch UUID print output. Defaultstdout. Possible values: [stderr, stdout].connect_timeout = 15- Connection timeout to ReportPortal server. Default value is “10.0”.read_timeout = 15- Response read timeout for ReportPortal connection. Default value is “10.0”.log_batch_size = 20- maximum number of log entries which will be sent by the agent at oncelog_batch_payload_size = 65000000- maximum payload size of a log batch which will be sent by the agent at onceIf you like to override the above parameters from command line, or from CI environment based on your build, then pass
--D parameter=valueduring invocation.LaunchingTo execute tests with ReportPortal you should runbehavecommand and specify path to feature files:behave./tests/featuresTest item attributesTagattributecould be used to specify attributes for features and scenarios.
Attributes should be listed inside brackets of attribute tag separated by commas.Example:@attribute(key:value,value2)@attribute(some_other_attribute)Feature:featurename@attribute(key:value,value2,value3)Scenario:scenarionameLoggingFor 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:importloggingfromreportportal_clientimportRPLogger,RPLogHandlerfrombehave_reportportal.behave_agentimportBehaveAgent,create_rp_servicefrombehave_reportportal.configimportread_configdefbefore_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=logLogger provides ability to attach some file in scope of log message (see examples below).in steps:@given("I want to calculate{number_a:d}and{number_b:d}")defcalculate_two_numbers(context,number_a,number_b):context.number_a=number_acontext.number_b=number_bcontext.log.info("log message")# Message with an attachment.importsubprocessfree_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 IDIt’s possible to mark some scenario withtest_case_id(<some_id>)tag. ID specified in brackets will be sent to ReportPortal.Integration with GAReportPortal 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.exportAGENT_NO_ANALYTICS=1Copyright NoticeLicensed under theApache 2.0license (see the LICENSE file).