allure-framework / allure-python

Allure integrations for Python test frameworks
https://allurereport.org/
Apache License 2.0
721 stars 236 forks source link

Allure report showing NaN% while using --device matrix capability in Json format #655

Open kunalbehl12 opened 2 years ago

kunalbehl12 commented 2 years ago

Hi Team,

I am facing issue to generate allure report using allure-pytest-bdd 2.9.45 version. We are passing browser capabilities by using Json file. [ { "local" : "true", "browser": "Chrome", "driver_path": "./binaries/webdriver/chromedriver", "resolution": "1900x1100", "headless": "true" } ]

python -m pytest -v --gherkin-terminal-reporter --tags "$TAGS" -n "$THREADS" --device-matrix "$CONFIG_JSON_FILE" --alluredir=output/reports/allure-results

It is creating extra dictionary in the allure json file due to which report is showing NaN% image

Json Result - { "name":"Navigate to championspfizercom with proxy enabled [chrome]", "status":"passed", "steps":[ { "name":"Given The browser resolution is '1367' per '768'", "status":"passed", "start":1648644612533, "stop":1648644615274 }, { "name":"Given I am on the url 'https://championspfizercom-preview.dev.pfizerstatic.io/'", "status":"passed", "start":1648644615276, "stop":1648644617743 }, { "name":"Then I expect that the title is not 'Sign in ・ Cloudflare Access'", "status":"passed", "start":1648644617749, "stop":1648644627957 }, { "name":"And I expect that the title is 'Alliance Anticoagulation Foundation | Homepage'", "status":"passed", "start":1648644627974, "stop":1648644627981 } ], "parameters":[ { "name":"custom_browser_config", "value":{ "local":"true", "browser":"Chrome", "driver_path":"./binaries/webdriver/chromedriver", "headless":"true" } } ], "start":1648644612528, "stop":1648644627982, "uuid":"1fae8e62-a32d-b230-6436-801757483f67", "historyId":"1fae8e62a32db2306436801757483f67", "fullName":"features\proxy.feature:Navigate to championspfizercom with proxy enabled", "labels":[ { "name":"host", "value":"DESKTOP-7MNDH5C" }, { "name":"thread", "value":"13280-MainThread" }, { "name":"framework", "value":"pytest-bdd" }, { "name":"language", "value":"cpython3" }, { "name":"feature", "value":"Tests to verify proxy config" } ] }

I'm submitting a ...

What is the current behavior?

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem

What is the expected behavior?

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

Kindly Advice.

kunalbehl12 commented 2 years ago

Any update on this? It is critical for my project. Any suggestions would be appreciated. Thanks!

delatrie commented 1 year ago

Test parameter values are not serialized properly by allure-pytest-bdd. This is not a problem for scenario outline parameters (as they are already strings) but this may be (and in this case - is) a problem for parameters provided through the pytest API (@pytest.mark.parametrize, metafunc.parametrize or fixture parametrization).

I will fix this eventually, but if someone is willing to contribute, they are welcome. What is needed is to wrap a parameter value with allure_commons.utils.represent function here: https://github.com/allure-framework/allure-python/blob/c1a4b0001b245a77ac3d2a3adc90df1bbebedebb/allure-pytest-bdd/src/utils.py#L50