@@ -26,14 +26,6 @@ testing infrastructure, and demonstrates how to write and run tests for a servic
26
26
- [ Special case: SAS tokens] ( #special-case-sas-tokens )
27
27
- [ Functional vs. unit tests] ( #functional-vs-unit-tests )
28
28
- [ Further reading] ( #further-reading )
29
- - [ Deprecated testing instructions] ( #deprecated-testing-instructions )
30
- - [ Define credentials (deprecated)] ( #define-credentials-deprecated )
31
- - [ Create live test resources (deprecated)] ( #create-live-test-resources-deprecated )
32
- - [ Write your tests (deprecated)] ( #write-your-tests-deprecated )
33
- - [ An example test (deprecated)] ( #an-example-test-deprecated )
34
- - [ Run and record the test (deprecated)] ( #run-and-record-the-test-deprecated )
35
- - [ Purging secrets (deprecated)] ( #purging-secrets-deprecated )
36
- - [ Special case: Shared Access Signature (deprecated)] ( #special-case-shared-access-signature-deprecated )
37
29
38
30
## Set up your development environment
39
31
@@ -191,6 +183,9 @@ User-based authentication is preferred when using test resources. To enable this
191
183
- Ensure you're logged into the tool you choose -- if
192
184
you used ` New-TestResources.ps1 ` to deploy resources, you'll already have logged in with Azure PowerShell.
193
185
186
+ ** Important:** these environment variables will only be successfully used if test credentials are fetched with the
187
+ [ ` AzureRecordedTestCase.get_credential ` ] [ get_credential ] method. See [ Write your tests] ( #write-your-tests ) for details.
188
+
194
189
If you haven't yet set up a ` test-resources ` file for test resource deployment and/or want to use test resources of
195
190
your own, you can just configure credentials to target these resources instead.
196
191
@@ -226,6 +221,9 @@ authenticate with by setting an `AZURE_TEST_USE_*_AUTH` environment variable to
226
221
3 . Visual Studio Code: set ` AZURE_TEST_USE_VSCODE_AUTH ` .
227
222
4 . Azure Developer CLI (` azd ` ): set ` AZURE_TEST_USE_AZD_AUTH ` .
228
223
224
+ ** Important:** these environment variables will only be successfully used if test credentials are fetched with the
225
+ [ ` AzureRecordedTestCase.get_credential ` ] [ get_credential ] method. See [ Write your tests] ( #write-your-tests ) for details.
226
+
229
227
If your service doesn't have a ` test-resources ` file for test deployment, you'll need to set environment variables
230
228
for authentication at minimum. For user-based authentication, use ` AZURE_TEST_USE_*_AUTH ` as described above.
231
229
@@ -327,6 +325,9 @@ AzureRecordedTestCase, EnvironmentVariableLoader, recorded_by_proxy`.
327
325
- The signature of your test method will always contain ` self ` , and following ` self ` will be all the keys that you
328
326
need from your preparer. A test does not need to accept every key from the preparer; the test framework will only pass
329
327
in the parameters specifically requested in the test method signature.
328
+ - Fetch a credential for your service client with [ ` self.get_credential ` ] [ get_credential ] . This is necessary for the
329
+ credential to be usable in playback tests, and for it to make use of the authentication method selected by
330
+ ` AZURE_TEST_USE_*_AUTH ` environment variables.
330
331
- Within tests, use the ` assert ` keyword to assert conditions that you expect to be true.
331
332
332
333
If you need logging functionality for your testing, pytest also offers [ logging] [ pytest_logging ] capabilities either
@@ -561,6 +562,7 @@ For information about more advanced testing scenarios, refer to the [advanced te
561
562
[ env_var_loader ] : https://github.com/Azure/azure-sdk-for-python/blob/main/tools/azure-sdk-tools/devtools_testutils/envvariable_loader.py
562
563
[ generate_sas ] : https://github.com/Azure/azure-sdk-for-python/blob/bf4749babb363e2dc972775f4408036e31f361b4/tools/azure-sdk-tools/devtools_testutils/azure_recorded_testcase.py#L196
563
564
[ generate_sas_example ] : https://github.com/Azure/azure-sdk-for-python/blob/3e3fbe818eb3c80ffdf6f9f1a86affd7e879b6ce/sdk/tables/azure-data-tables/tests/test_table_entity.py#L1691
565
+ [ get_credential ] : https://github.com/Azure/azure-sdk-for-python/blob/20cf5b0bd9b87f90bd5ad4fd36358d3b257f95c5/tools/azure-sdk-tools/devtools_testutils/azure_recorded_testcase.py#L96
564
566
[ git_setup ] : https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup
565
567
[ kv_test_resources ] : https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/keyvault/test-resources.json
566
568
[ kv_test_resources_outputs ] : https://github.com/Azure/azure-sdk-for-python/blob/fbdb860630bcc13c1e355828231161849a9bd5a4/sdk/keyvault/test-resources.json#L255
0 commit comments