Skip to content

Improvement for test, #789 and #788 #816

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 6, 2021
Merged

Conversation

dolauli
Copy link
Contributor

@dolauli dolauli commented Aug 6, 2021

Live Only Test

Describe 'New-AzDatabricksWorkspace' -Tag 'LiveOnly'{
}

Run Specific Test Cases

./test-module.ps1 -TestName Get-AzDatabricksWorkspace,New-AzDatabricksWorkspace

Record Specific Test Cases

# -UsePreviousConfigForRecord
# When this switch is turned on, we will try to use values defined in env.json instead of randomly
# generating them 
./test-module.ps1 -TestName Get-AzDatabricksWorkspace,New-AzDatabricksWorkspace -Record -UsePreviousConfigForRecord

Required Code Change to Support Recording Specific Cases

Change #1

Previous

$null = $env.Add("rstr5", $rstr5)

Now

$rstr5 = $env.AddWithCache("rstr5", $rstr5, $UsePreviousConfigForRecord)

Or

Use following if some values are generated in service side.

$rstr5 = $env.AddWithCache("rstr5", $rstr5, $false)

Change #2

Add following if clause in the header of each test script which ends with .Tests.ps1. And you should replace 'Get-AzDatabricksVNetPeering' with the name in your test Describe.

if (($null -eq $TestName) -or ($TestName -contains 'Get-AzDatabricksVNetPeering')) {
    $loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1'
		.....
		. ($mockingPath | Select-Object -First 1).FullName
}

Limitations When Supporting Recording Specific Cases

Subscription can not be changed

Solutions:

  • Full record
  • After partial recording, replace the old subscription Id with the new one

Some data is generated in service side

For data like this, we can not use the previous one in env.json.

@dolauli dolauli merged commit d40c02d into Azure:main Aug 6, 2021
@dolauli dolauli deleted the testimprovement branch October 26, 2021 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant