Package: pytest-tm4j-reporter
Project summaryPytest plugin which allows to upload test execution result toTM4J Cloudversion. Plugin works on the top of thejson-reporterpytest plugin andtm4j_reporter_apilibrary.Install and setupHow to buildpython setup.py sdistHow to install# PyPi
pip install pytest-tm4j-reporter
# Git
pip install git+ssh://git@github.com:Klika-Tech/tm4j_reporter_pytest.gitPlugin configurationCreatepytest.iniwithin your project and put the variables there (see below table)ParamMandatoryDescriptionExampletm4j_project_prefixYesJira / TM4J project prefix without trailing dashQTtm4j_api_keyYesAPI key to access TM4j. To get it seeInstructiontm4j_testcycle_keyNoTM4J existing test cycle key. A new test cycle created if not specifiedR40tm4j_testcycle_prefixNoPrefix for new test cycle. Default: autoreport. Full test cycle name is " ". e.g. "14-Jul-2020 16:41:24 UTC"Login autoteststm4j_testcycle_descriptionNoDescription for the new test cycle. A description for the existing test cycle won't be changedUpdate v14.43.136tm4j_project_webui_hostNoJira server base host. If provided will generate a link to a newly created test cycleklika-tech.atlassian.nettm4j_result_mappingNoHow to map test result - Pytest vs TM4J. tm4j-default (default) or pytest. see "Result mapping" sectiontm4j-defaultExample:[pytest]tm4j_project_prefix=QTtm4j_api_key=eyJ0eXAiOiJKV1QiLCJhbtm4j_testcycle_key=R40tm4j_testcycle_prefix=login teststm4j_testcycle_description=Update v14.43.136tm4j_project_webui_host=klika-tech.atlassian.netUsageWriting the testsTo be able to report your test to TM4J your test names should follow convetion:test_T<TM4J test id>_the_rest_of_test_name.So workflow will be:Create test case in TM4J (from UI)Notice it's unique idCreate test in pytest with TM4J prefix in name.Let's say in TM4J project with project keyQTfull test key isQT-T1234. In this case in pytest it should be created likedeftest_T1234_login_as_user():...testcodegoeshereResult mappingPytest has test result status names different from TM4JThe mapping is configured viatm4j_result_mappingparameter (optional)Possible values: tm4j-default (default), pytestBy default, the statuses are mapped according to the following scheme:PytestTM4JDescriptionpassedPassfailedFailskippedNot executedxfailedPassFailed, as it shouldxpassedFailShould fail, but was passedTM4J test result statuses are configurableFor more precise mapping, pytest statuses can be added to TM4J via its UIPytestTM4JpassedPassfailedFailskippedSkipxfailedxFailxpassedxPasstm4j_result_mapping=pytest will activate this schemeMetadataIt is possible to add and report additional metadata usingtm4j_rfixture. Currently supported onlycomment. Example:deftest_T1701_my_test(tm4j_r):tm4j_r.comment='Here might be some comment for this test<br>second line here<br>third line here'The published comment field will also contain a crash info in case if the test execution fails. Example:crash info:
path: /opt/work/tm4j_reporter_pytest/tests/common/report_tests.py
lineno: 17
message: assert FalsePlease note that if you use tm4j_r fixture you won't be able to run the test without enabling plugin--tm4jHow to runFinally we're ready to run our test(s) with reporting to TM4J. It is simple as just run pytest with--tm4joption--tm4j-no-publishflag can be used if you don't want to publish your execution results to TM4Jpytest--tm4jResult.report.json file created in CWDThe file is overwritten each timeExecution result is uploaded to TM4JDeveloper notesLine wrapping border = 120 charsLicenseThis software is licensed under theMIT License