Package: tm4j-reporter-robot
Project summaryPackage providing Robot Framework listener for TM4J Cloud integration.InstallHow to buildpython setup.py sdistHow to install# PyPi
pip install tm4j-reporter-robot
# Git
pip install git+ssh://git@github.com:Klika-Tech/tm4j_reporter_robot.gitUsageIn order to use Robot Framework TM4J listener, it should be installed to the same PYTHONPATH as Robot Framework itself.Listener requires arguments below to be passed:ParamMandatoryEnvironment variable nameDescriptionTypeExampletm4j_access_keyYesTM4J_ACCESS_KEYAPI key to access TM4j. To get it seeInstructionstrtm4j_project_keyYesTM4J_PROJECT_KEYJira / TM4J project prefix without trailing dashstrQTparallel_execution_flagNoTM4J_PARALLEL_EXECUTION_SUPPORTFlag to mark parallel execution. False by defaultbooleantruepath_to_shared_test_cycle_key_fileNoTM4J_SHARED_TEST_CYCLE_KEY_FILE_PATHPath to TM4J test cycle key shared file (used to handle parallel test execution). Deault value is{os_tempdir}/TEST_CYCLE_KEYstr/my_folder/my_test_cycle_key_filetm4j_test_cycle_nameNoTM4J_TEST_CYCLE_NAMETM4J test cycle name. If not passed, listener will create a new one test cycle with default name "Robot run YYYY-mm-DD HH-MM-SS"strMy test cycleListener will try to get attribute value from environment variables first, and if attribute is not set as environment variable - will look up to command line parameter.Passing attributes from environmentYou can set all or required only attributes as environment variables, so no need to pass them into command line:exportTM4J_ACCESS_KEY=<my_access_key>exportTM4J_PROJECT_KEY=QTWith that you can pass only non-required attributes to customize your test run:pabot--processes4--listenertm4j_reporter_robot.TM4JRobotListener:::true:/my_user/temp/my_tc_key:"My custom test cycle name"tests/If needed, you can set all arguments as environment variables, so command line will be simply short:# setting the rest of variablesexportTM4J_PARALLEL_EXECUTION_SUPPORT=trueexportTM4J_SHARED_TEST_CYCLE_KEY_FILE_PATH=/my_user/temp/my_tc_keyexportTM4J_TEST_CYCLE_NAME="My custom test cycle name"# running testspabot--processes4--listenertm4j_reporter_robot.TM4JRobotListenertests/Passing attributes from command lineWhile running Robot Framework, passTM4JRobotListeneras value for--listenerargument, along with access and project keys:robot--listenertm4j_reporter_robot.TM4JRobotListener:<tm4j_access_key>:<tm4j_project_key>:<parallel_execution_flag>:<path_to_shared_test_cycle_key_file>:<tm4j_test_cycle_name>test.robotExample:running without parallel execution with custom test cycle namerobot--listenertm4j_reporter_robot.TM4JRobotListener:my_access_key:QT:::"My custom test cycle name"test.robotExample:parallel execution withpabotand cleanup before runrm-rf/my_user/temp/my_tc_key*
pabot--processes4--listenertm4j_reporter_robot.TM4JRobotListener:my_access_key:QT:true:/my_user/temp/my_tc_key:"My custom test cycle name"tests/Tests preparationIn order to listener reported test execution to TM4J, mark Robot test case with tagTM4J:<tm4j_test_case_key>:My Robot Test Case
    [Tags]  Some tag 1  Some tag 2  TM4J:QT-001
    test code goes hereParallel executionFor parallel execution with e.g.pabot, you need to set parallel execution flag totrue.Listener uses synchronization through shared file for test cycle key and lock file - so only one process \ thread will create TM4J test cycle for execution, write its key into a shared file, and all other processes \ threads read test cycle key from it.Unfortunately, Robot API doesn't have any methods that called before or after ALL executions, so you need to delete shared test cycle key file and lock file manually after run. The best way is to create some pre-execution script (similar to example above) that will do this cleanup for you.IMPORTANT: If you not delete those files, your next run will report test executions into previously created TM4J test cycle.ExceptionsTM4JConfigurationExceptionRaised by listener if test is not tagged with TM4J test case key:tm4j_reporter_api.tm4j_exceptions.tm4j_configuration_exceptions.TM4JConfigurationException:Testcasekeyisnotfoundinlistoftags.Pleasemarkrobottestwithtag'TM4J:<test_case_key>'.TM4J test cycle description keywordLibrary provides possibility to set TM4J test cycle description with special keywordSet Tm4j Test Cycle Description.UsageImport library first, use keyword after:*** Settings ***
Library  tm4j_reporter_robot.TM4JCycleDescriptor
Suite Setup  Setting Cycle Description


*** Keywords ***
Setting Cycle Description
    Set Tm4j Test Cycle Description  My test cycle descriptionKeyword is in global scope, so only one instance is created during the whole test execution and it is shared by all test cases and test suites.