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
Copy file name to clipboardExpand all lines: sdk/core/Azure.Core.TestFramework/README.md
+51-7Lines changed: 51 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -227,14 +227,13 @@ public class ConfigurationLiveTests: RecordedTestBase<AppConfigurationTestEnviro
227
227
}
228
228
```
229
229
230
-
231
-
## Recording
230
+
### Recording
232
231
233
232
When tests are run in recording mode, session records are saved to the project directory automatically in a folder named 'SessionRecords'.
234
233
235
234
__NOTE:__ recordings are copied from `netcoreapp2.1` directory by default, make sure you are running the right target framework.
236
235
237
-
## Sanitizing
236
+
###Sanitizing
238
237
239
238
Secrets that are part of requests, responses, headers, or connections strings should be sanitized before saving the record.
240
239
**Do not check in session records containing secrets.** Common headers like `Authentication` are sanitized automatically, but if custom logic is required and/or if request or response body need to be sanitized, the `RecordedTestSanitizer` should be used as an extension point.
@@ -271,7 +270,7 @@ Another sanitizer property that is available for sanitizing Json payloads is the
271
270
}
272
271
```
273
272
274
-
## Matching
273
+
###Matching
275
274
276
275
When tests are run in replay mode, HTTP method, Uri and headers are used to match the request to the recordings. Some headers change on every request and are not controlled by the client code and should be ignored during the matching. Common headers like `Date`, `x-ms-date`, `x-ms-client-request-id`, `User-Agent`, `Request-Id` are ignored by default but if more headers need to be ignored, use `RecordMatcher` extensions point.
277
276
@@ -295,7 +294,7 @@ When tests are run in replay mode, HTTP method, Uri and headers are used to matc
295
294
}
296
295
```
297
296
298
-
## Misc
297
+
###Misc
299
298
300
299
You can use `Recording.GenerateId()` to generate repeatable random IDs.
301
300
@@ -309,7 +308,7 @@ You can use `if (Mode == RecordingMode.Playback) { ... }` to change behavior for
309
308
310
309
You can use `using (Recording.DisableRecording()) { ... }` to disable recording in the code block (useful for polling methods)
311
310
312
-
# Support multi service version testing
311
+
##Support multi service version testing
313
312
314
313
To enable multi-version testing, add the `ClientTestFixture` attribute listing to all the service versions to the test class itself or a base class:
[TestEnvVar](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/core/Azure.Core.TestFramework/src/TestEnvVar.cs) allows you to wrap a block of code with a using statement inside which the configured Environment variables will be set to your supplied values.
using (var_=newTestEnvVar("AZURE_TENANT_ID", "foo"))
474
+
{
475
+
// Test code that relies on the value of AZURE_TENANT_ID
476
+
}
477
+
478
+
// The previous value of AZURE_TENANT_ID is set again here.
479
+
```
480
+
481
+
### TestAppContextSwitch
482
+
483
+
[TestAppContextSwitch](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/core/Azure.Core.TestFramework/src/TestAppContextSwitch.cs) allows you to wrap a block of code with a using statement inside which the configured [AppContext](https://docs.microsoft.com/dotnet/api/system.appcontext) switch will be set to your supplied values.
0 commit comments