|
| 1 | +Dynamic parameter |
| 2 | +------------------- |
| 3 | + |
| 4 | +It's possible to dynamically add a parameter to a test result: |
| 5 | + |
| 6 | + |
| 7 | + >>> import allure |
| 8 | + |
| 9 | + >>> def test_dynamic_parameter(): |
| 10 | + ... allure.dynamic.parameter("username", "John Doe") |
| 11 | + |
| 12 | + |
| 13 | +The parameter name and value are shown in the "Parameters" section of the test |
| 14 | +details view. Additionally, the value is shown near the test name in the test |
| 15 | +tree view. |
| 16 | + |
| 17 | + |
| 18 | +Affecting the history of test execution in Allure TestOps |
| 19 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 20 | + |
| 21 | +Parameters also affect how Allure TestOps keeps test history and retry records |
| 22 | +across test results. Two test results that differs from each other in a |
| 23 | +parameter value are considered as belonging to different test cases, thus |
| 24 | +forming separate histories. |
| 25 | + |
| 26 | +This behavior can be changed with ``excluded`` argument: |
| 27 | + |
| 28 | + |
| 29 | + >>> import allure |
| 30 | + ... import os |
| 31 | + |
| 32 | + >>> def test_excluded_dynamic_parameter(): |
| 33 | + ... allure.dynamic.parameter("work-dir", os.getcwd(), excluded=True) |
| 34 | + |
| 35 | + |
| 36 | +Such a parameter isn't taken into account by Allure TestOps when it decides |
| 37 | +whether two test results actually belong to a single test case. This is useful |
| 38 | +if you want to add environment-related information (such as host names, OS, PID, |
| 39 | +paths, versions, etc.) but keep history the same if the information is changed. |
| 40 | + |
| 41 | + |
| 42 | +Masking a sensitive parameter |
| 43 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 44 | + |
| 45 | +A parameter value can be masked with ``mode`` argument. The masked value is shown |
| 46 | +as `******` in the report. This is useful for sensitive parameters like |
| 47 | +passwords or key phrases: |
| 48 | + |
| 49 | + |
| 50 | + >>> import allure |
| 51 | + |
| 52 | + >>> def test_masked_dynamic_parameter(): |
| 53 | + ... allure.dynamic.parameter("password", "qwerty", mode=allure.parameter_mode.MASKED) |
| 54 | + |
| 55 | + |
| 56 | +.. warning:: Although the value is masked in the report, it is still present in the |
| 57 | + test result files (but not in report files, i.e., generated by allure |
| 58 | + reporter). |
| 59 | + |
| 60 | + |
| 61 | +Hiding a parameter from the report |
| 62 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 63 | + |
| 64 | +A parameter can be hidden from the report completely. It still affects the |
| 65 | +history of the test case though. This is useful if you want to force Allure |
| 66 | +TestOps to distribute otherwise indistinguishable test results across different |
| 67 | +test cases: |
| 68 | + |
| 69 | + |
| 70 | + >>> import allure |
| 71 | + ... import socket |
| 72 | + |
| 73 | + >>> def test_hidden_dynamic_parameter(): |
| 74 | + ... allure.dynamic.parameter("hostname", socket.gethostname(), mode=allure.parameter_mode.HIDDEN) |
0 commit comments