问题:
表格中的测试用例参数化后通过allure生成报告的Parameters内容显示太多,不美观
在网上找到一个方法是在 Lib->site-packages->allure-pytest->listener.py,修改以下代码
# 修改前
test_result.parameters.extend(
[Parameter(name=name, value=represent(value)) for name, value in params.items()
if name not in current_param_names])
# 修改后 (将列表内容去除即可)
test_result.parameters.extend([])
但是在新版allure中不适用,会导致用例丢失,去看了社区中的描述得到下面的解决方案
解决方案:
Parameters重写
allure.dynamic.parameter("testcases", "123")
没有研究出来如何隐藏Patameters,
allure.dynamic.parameter(name, value, excluded=None, mode=None)
Specify a
name
andvalue
of a parameter that was used during this test.This can be used for adding the parameters even to those function that do not use the pytest's parametrization features. In the second example below, there are no test parameters as far as pytest is concerned, however, the test report will display the “login” parameter.
You can also override display values for the existing parameters. In the third example below, the test report will use the short value for the parameter instead of the full path. Note that changing the display value does not affect the unique identifier for the tests history.
The parameters can be used in the test's title, see Title.
If the
excluded
argument is set to True, Allure will not use the parameter when comparing the current test result with previous one in the history. This argument is only used by Allure TestOps.The
mode
argument affects how the parameter will be displayed in the report. Available options are defined in theallure.parameter_mode
enumeration:
allure.parameter_mode.DEFAULT
(same as not specifying any mode) — the parameter and its value will be shown in a table along with other parameters.allure.parameter_mode.MASKED
— the parameter will be shown in the table, but its value will be hidden. Use this mode for passwords, tokens and other sensitive parameters.allure.parameter_mode.HIDDEN
— the parameter and its value will not be shown in the test report. Note, however, that it is still possible to extract the value from theallure_results
directory if you publish it.
mode好像没有用一样,用allure.parameter_mode.HIDDEN隐藏不了,不知道是不是理解上有问题