Code Monkey home page Code Monkey logo

Comments (5)

DenKos363 avatar DenKos363 commented on May 26, 2024

Allure output for test, failed with 'with check:'

/home/den/Codding/logs/rep_27_07_check/fd002fa9-9f2b-42ae-8961-0dc37074ea72-result.json:1:{"name": "test_fail_scenario[4-5-G/C-json_result0]", "status": "failed", "parameters": [{"name": "first_source", "value": "4"}, {"name": "second_source", "value": "5"}, {"name": "result", "value": "'G/C'"}, {"name": "json_result", "value": "{'additional_text': 'Entertainment stop', 'additional_text_info': 'Info stop', 'additional_text_after_stop_interruption': '', 'additional_text_info_after_stop_interruption': '', 'source_id_state': '2', 'interrupt_id_state': '0', 'source_action': '2', 'interrupt_action': '0', 'action_after_stop_interruption': '', 'source_id_state_after_stop_interruption': '0'}"}], "start": 1595866982848, "stop": 1595866986382, "uuid": "cfd0cf0e-de4b-4183-9445-0149a45a96a9", "historyId": "bed0cfa61c2e91ba71667fc442eb4b72", "fullName": "regression.audiomanagement.test_jira_reporting#test_fail_scenario[4-5-G/C-json_result0]", "labels": [{"name": "parentSuite", "value": "regression.audiomanagement"}, {"name": "suite", "value": "test_jira_reporting"}, {"name": "host", "value": "den-pc"}, {"name": "thread", "value": "151296-MainThread"}, {"name": "framework", "value": "pytest"}, {"name": "language", "value": "cpython3"}, {"name": "package", "value": "regression.audiomanagement.test_jira_reporting"}], "links": [{"type": "link", "url": "", "name": "Second"}]}

Allure output for test, failed with 'assert'
/home/den/Codding/logs/rep_27_07/ec67058d-f9db-4b1a-ace5-380a19c065be-result.json:1:{"name": "test_fail_scenario[4-5-G/C-json_result0]", "status": "failed", "statusDetails": {"message": "AssertionError: [['Expected =>>> audioSourceId: 4 Action: 2', \"Actual =>>> ['01-01 06:31:16.508 3029 3029 I CommandReceiver: OnReceive...: 5 state: 0 type: 0 priority type: 5 reason: 0']\"], 'Combination 4 and 5', 'Expected arbitration table result is G/C']\nassert not [['Expected =>>> audioSourceId: 4 Action: 2', \"Actual =>>> ['01-01 06:31:16.508 3029 3029 I CommandReceiver: OnReceive...: 5 state: 0 type: 0 priority type: 5 reason: 0']\"], 'Combination 4 and 5', 'Expected arbitration table result is G/C']", "trace": "first_source = 4, second_source = 5, result = 'G/C'\njson_result = {'action_after_stop_interruption': '', 'additional_text': 'Entertainment stop', 'additional_text_after_stop_interruption': '', 'additional_text_info': 'Info stop', ...}\n\n @allure.link('',\n name='Second')\n @pytest.mark.parametrize(\"first_source, second_source, result, json_result\", parameter_gatherer1())\n def test_fail_scenario(first_source, second_source, result, json_result):\n current_timestamp = logcat.get_current_logcat_timestamp()\n logger.info(\"Test started for {0} and {1}\".format(first_source, second_source))\n AmmTestApp().source_change_start(first_source)\n assert not check_source_state_sc_start(first_source, current_timestamp)\n current_timestamp = logcat.get_current_logcat_timestamp()\n AmmTestApp().source_change_start(second_source)\n assert not check_source_state_sc_start(second_source, current_timestamp)\n sc_start_actions = ent_ent_validator.check_source_state_sc_start(result=result,\n source_id_source=first_source,\n source_id_new=second_source,\n source_action=json_result[\"source_action\"],\n interrupt_action=json_result[\"interrupt_action\"],\n interrupt_id_state=json_result[\n \"interrupt_id_state\"],\n current_timestamp=current_timestamp)\n> assert not sc_start_actions, sc_start_actions\nE AssertionError: [['Expected =>>> audioSourceId: 4 Action: 2', \"Actual =>>> ['01-01 06:31:16.508 3029 3029 I CommandReceiver: OnReceive...: 5 state: 0 type: 0 priority type: 5 reason: 0']\"], 'Combination 4 and 5', 'Expected arbitration table result is G/C']\nE assert not [['Expected =>>> audioSourceId: 4 Action: 2', \"Actual =>>> ['01-01 06:31:16.508 3029 3029 I CommandReceiver: OnReceive...: 5 state: 0 type: 0 priority type: 5 reason: 0']\"], 'Combination 4 and 5', 'Expected arbitration table result is G/C']\n\ntest_jira_reporting.py:74: AssertionError"}, "parameters": [{"name": "first_source", "value": "4"}, {"name": "second_source", "value": "5"}, {"name": "result", "value": "'G/C'"}, {"name": "json_result", "value": "{'additional_text': 'Entertainment stop', 'additional_text_info': 'Info stop', 'additional_text_after_stop_interruption': '', 'additional_text_info_after_stop_interruption': '', 'source_id_state': '2', 'interrupt_id_state': '0', 'source_action': '2', 'interrupt_action': '0', 'action_after_stop_interruption': '', 'source_id_state_after_stop_interruption': '0'}"}], "start": 1595866724999, "stop": 1595866728622, "uuid": "a9de0202-b248-43c1-a67d-fb5a3d140521", "historyId": "bed0cfa61c2e91ba71667fc442eb4b72", "fullName": "regression.audiomanagement.test_jira_reporting#test_fail_scenario[4-5-G/C-json_result0]", "labels": [{"name": "parentSuite", "value": "regression.audiomanagement"}, {"name": "suite", "value": "test_jira_reporting"}, {"name": "host", "value": "den-pc"}, {"name": "thread", "value": "150849-MainThread"}, {"name": "framework", "value": "pytest"}, {"name": "language", "value": "cpython3"}, {"name": "package", "value": "regression.audiomanagement.test_jira_reporting"}], "links": [{"type": "link", "url": "", "name": "Second"}]}
`

As I can see, 'assert' has statusDetails section, and it takes as AssertionError in html. Is it possible to send something into this section with help of plugin?

UDP:
manual adding of this information into the report with with check: (assertion type) started display expected information:

"statusDetails": {"message": "AssertionError: [['Expected =>>> audioSourceId: 4 Action: 2', \"Actual =>>> ['01-01 06:31:16.508 3029 3029 I CommandReceiver: OnReceive...: 5 state: 0 type: 0 priority type: 5 reason: 0']\"], 'Combination 4 and 5', 'Expected arbitration table result is G/C']"},
Screenshot from 2020-07-27 19-47-03

from pytest-check.

DenKos363 avatar DenKos363 commented on May 26, 2024

Additional information - during using regular 'assert' there is reprcrash parameter, which, I think, leads to the "statusDetails" message in Allure
Screenshot from 2020-07-28 15-26-51

If I use 'with check:' - there is only 'longrepr' and 'longreprtext' with error
Screenshot from 2020-07-28 15-34-47

from pytest-check.

DenKos363 avatar DenKos363 commented on May 26, 2024

If anybody interested in the same problem, I workaround it with help of this code in conftest.py

@pytest.hookimpl(tryfirst=True, hookwrapper=True)
def pytest_runtest_makereport(item, call):
    outcome = yield
    rep = outcome.get_result()
    if rep.when == 'call' and rep.failed:
        allure.attach(rep.longreprtext, name="errr_log")

In this case file with all errors will be attached to allure report as "errr_log" file

from pytest-check.

okken avatar okken commented on May 26, 2024

@DenKos363 Thanks for posting the workaround. very cool.

from pytest-check.

okken avatar okken commented on May 26, 2024

Leaving this open so I can try it out and add to documentation.

from pytest-check.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.