|
| 1 | +# Run unit tests and integration tests |
| 2 | +Param( |
| 3 | + [string] |
| 4 | + [Parameter(Mandatory=$false)] |
| 5 | + [ValidateSet("Debug", "Release")] |
| 6 | + $Configuration = "Debug", |
| 7 | + |
| 8 | + [switch] |
| 9 | + [Parameter(Mandatory=$false)] |
| 10 | + $Help |
| 11 | +) |
| 12 | + |
| 13 | +function Show-Usage { |
| 14 | + Write-Host " This runs both unit tests and integration tests. |
| 15 | +
|
| 16 | + Usage: $(Split-Path $MyInvocation.ScriptName -Leaf) `` |
| 17 | + [-Configuration <Configuration>] `` |
| 18 | +
|
| 19 | + [-Help] |
| 20 | +
|
| 21 | + Options: |
| 22 | + -Configuration Configuration. Possible values are 'Debug' or 'Release'. Default is 'Debug'. |
| 23 | +
|
| 24 | + -Help: Show this message. |
| 25 | +" |
| 26 | + |
| 27 | + Exit 0 |
| 28 | +} |
| 29 | + |
| 30 | +# Builds apps |
| 31 | +Write-Host "Building apps..." -ForegroundColor Cyan |
| 32 | + |
| 33 | +dotnet restore |
| 34 | +dotnet build -c $Configuration |
| 35 | + |
| 36 | +# Runs unit tests |
| 37 | +Write-Host "Invoking unit tests..." -ForegroundColor Cyan |
| 38 | + |
| 39 | +dotnet test ./test/AzureOpenAIProxy.AppHost.Tests -c $Configuration --no-build --logger "trx" --collect:"XPlat Code Coverage" |
| 40 | +dotnet test ./test/AzureOpenAIProxy.ApiApp.Tests -c $Configuration --no-build --logger "trx" --collect:"XPlat Code Coverage" |
| 41 | + |
| 42 | +# Runs integration tests |
| 43 | +Write-Host "Invoking integration tests..." -ForegroundColor Cyan |
| 44 | + |
| 45 | +$playwright = Get-ChildItem -File Microsoft.Playwright.dll -Path . -Recurse |
| 46 | +$installer = "$($playwright[0].Directory.FullName)/playwright.ps1" |
| 47 | +& "$installer" install |
| 48 | + |
| 49 | +Start-Process -NoNewWindow "dotnet" @("run", "--project", "./src/AzureOpenAIProxy.AppHost", "--no-build") |
| 50 | +Start-Sleep -s 30 |
| 51 | + |
| 52 | +dotnet test ./test/AzureOpenAIProxy.PlaygroundApp.Tests -c $Configuration --logger "trx" --collect:"XPlat Code Coverage" |
| 53 | + |
| 54 | +# Cleans up |
| 55 | +$process = if ($IsWindows -eq $true) { |
| 56 | + Get-Process | Where-Object { $_.ProcessName -eq "AzureOpenAIProxy.AppHost" } |
| 57 | +} else { |
| 58 | + Get-Process | Where-Object { $_.Path -like "*AzureOpenAIProxy.AppHost" } |
| 59 | +} |
| 60 | +Stop-Process -Id $process.Id |
0 commit comments