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: documentation/development-docs/azure-powershell-developer-guide.md
+44-6Lines changed: 44 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -248,17 +248,58 @@ _Note_: As mentioned in the prerequisites section, set the PowerShell [execution
248
248
249
249
## Using Azure TestFramework
250
250
251
-
Please see our guide on [Using Azure TestFramework](../testing-docs/using-azure-test-framework.md) for information on how to setup the appropriate connection string and record tests using the `Microsoft.Rest.ClientRuntime.Azure.TestFramework` package.
251
+
Please see our guide on [Using Azure TestFramework](../testing-docs/using-azure-test-framework.md) for information on how to setup the appropriate connection string and record tests.
252
252
253
253
## Scenario Tests
254
254
255
+
### Adding Test Project
256
+
257
+
- Create a new folder called `ScenarioTests`
258
+
- Create a new folder called `SessionRecords`
259
+
- Inside the `ScenarioTests` folder, create a new class called `<SERVICE>TestRunner`
260
+
- In the `<SERVICE>TestRunner` class, it should have the similar field and constructor like shown below. The parameter values passed in are based on the real situation.
- The new class must inherit from the `<SERVICE>TestRunner` class in this project.
258
298
- Add `[Fact]` as an attribute to every test
259
299
- Add `[Trait(Category.AcceptanceType, Category.CheckIn)]` as an attribute to any test that should be run during CI in Playback mode.
260
300
- Add `[Trait(Category.AcceptanceType, Category.LiveOnly)]` as an attribute to any test that cannot be run in Playback mode (for example, if a test depends on a Dataplane SDK).
261
-
- Create a ps1 file in the same folder that contains the actual tests ([see sample](../../src/Media/Media.Test/ScenarioTests))
301
+
- Create a ps1 file in the same folder that contains the actual tests.
302
+
- The name of the ps1 file should exactly match with name of the class. ([see sample](../../src/Media/Media.Test/ScenarioTests))
262
303
- Use `Assert-AreEqual x y` to verify that values are the same
263
304
- Use `Assert-AreNotEqual x y` to verify that values are not the same
264
305
- Use `Assert-Throws scriptblock message` to verify an exception is being thrown
@@ -302,10 +343,7 @@ Create this environment variables for the AD scenario tests:
302
343
### Recording/Running Tests
303
344
304
345
- Set up environment variables using New-TestCredential as described [here](../testing-docs/using-azure-test-framework.md#new-testcredential)
305
-
- Run the test in Visual Studio in the Test Explorer window and make sure you got a generated JSON file that matches the test name in the bin folder under the `SessionRecords` folder
306
-
- Copy this `SessionRecords` folder and place it inside the test project
307
-
- Inside Visual Studio, add all of the generated JSON files, making sure to change the "Copy to Output Directory" property for each one to "Copy if newer"
308
-
- Make sure that all of these JSON files appear in your `<SERVICE>.Test.csproj` file
346
+
- Run the test in Visual Studio in the Test Explorer window and make sure you got a generated JSON file that matches the test name under the `SessionRecords` folder
Copy file name to clipboardExpand all lines: documentation/testing-docs/using-azure-test-framework.md
+3-6Lines changed: 3 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,11 +28,9 @@
28
28
- Import the `Repo-Tasks` module that helps to perform basic repository tasks
29
29
- Run the command `Import-Module .\Repo-Tasks.psd1`
30
30
31
-
## Acquiring TestFramework
31
+
## Azure PowerShell TestFramework
32
32
33
-
The `TestFramework` library is available on NuGet at https://www.nuget.org/packages/Microsoft.Rest.ClientRuntime.Azure.TestFramework/ .
34
-
35
-
Instructions on manually downloading the library are available on NuGet, however, `TestFramework` will automatically be downloaded as part of the build process, so the manual download is usually not necessary.
33
+
Azure PowerShell repo now has its own test framework located under `tools\TestFx`, which supports recording all the HTTP requests from behind Azure PowerShell cmdlets and then playing them back.
36
34
37
35
The target framework of test is .Net Core 3.1, please ensure .Net runtime Microsoft.NETCore.App 3.1 is installed. You can list all installed version via `dotnet --info`.
38
36
@@ -129,8 +127,7 @@ AZURE_TEST_MODE=Record
129
127
130
128
## Record or Playback Tests
131
129
132
-
-[Run the tests](https://github.com/Azure/azure-powershell/blob/main/documentation/development-docs/azure-powershell-developer-guide.md#recordingrunning-tests) and make sure that you got a generated `.json` file that matches the test name in the bin folder under the `SessionRecords` folder
133
-
- Copy the `SessionRecords` folder inside the test project and add all `*.json` files in Visual Studio setting "Copy to Output Directory" property to "Copy if newer"
130
+
-[Run the tests](https://github.com/Azure/azure-powershell/blob/main/documentation/development-docs/azure-powershell-developer-guide.md#recordingrunning-tests) and make sure that you got a generated `.json` file that matches the test name under the `SessionRecords` folder in the test project.
134
131
- To assure that the records work fine, delete the connection string (default mode is Playback mode) OR change HttpRecorderMode within the connection string to "Playback" and run the tests
0 commit comments