You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, in order to have a "variables" collection, you need to specify it in the signature and return it from the test method. This means that your test method body has to be aware of whether the test is being run live or not. The test author should not have to have conditional "live" checks as this will bloat the test and make it more difficult to reason about.
It would be preferable if the test author could handle variables in a decorator, preparer, fixture, etc, similar to the woefully misnamed PowerShellPreparer. That preparer handles environment variables. If present, it uses those values--otherwise it uses a static value.
A VariablesPreparer would function similarly:
if the test is being played back, it will load the value for the recording's "variables" collection
if the test is running live, it will generate a random value and store it in the variables collection for playback
For each item in the VariabesPreparer, the author should be able to specify a prefix, if desired, for easier debugging. Using a preparer might also negate the need to modify the test body to return the variables collection, as the variables will not (and should not!) be manipulated in the test method body.
The text was updated successfully, but these errors were encountered:
This is now addressed with the recommended use of the built-in setdefault dictionary method when using @recorded_by_proxy(_async) decorators, and with the variable_recorder fixture when using the recorded_test fixture.
https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/test_proxy_migration_guide.md#record-test-variables
Currently, in order to have a "variables" collection, you need to specify it in the signature and return it from the test method. This means that your test method body has to be aware of whether the test is being run live or not. The test author should not have to have conditional "live" checks as this will bloat the test and make it more difficult to reason about.
It would be preferable if the test author could handle variables in a decorator, preparer, fixture, etc, similar to the woefully misnamed
PowerShellPreparer
. That preparer handles environment variables. If present, it uses those values--otherwise it uses a static value.A
VariablesPreparer
would function similarly:For each item in the VariabesPreparer, the author should be able to specify a prefix, if desired, for easier debugging. Using a preparer might also negate the need to modify the test body to return the variables collection, as the variables will not (and should not!) be manipulated in the test method body.
The text was updated successfully, but these errors were encountered: