Skip to content

Instantly share code, notes, and snippets.

@lawrencegripper
Created March 10, 2017 09:15
Show Gist options
  • Select an option

  • Save lawrencegripper/bf370eb9ae5cd9cfea5f2cad6d8826b8 to your computer and use it in GitHub Desktop.

Select an option

Save lawrencegripper/bf370eb9ae5cd9cfea5f2cad6d8826b8 to your computer and use it in GitHub Desktop.
Quick script to run a simple webtest from powershell, setting contextParameters and capturing the results.
#
# Run_PostDeployWebTest.ps1
#
Param(
[string][Parameter(Mandatory=$true)]$WebTestPath,
[string][Parameter(Mandatory=$true)]$PublicUrl,
[string][Parameter(Mandatory=$true)]$OutputDir,
[string]$OutputFileName = "WebTestResult.xml"
)
#Runs the basic browse test to check things are behaving.
if (Test-Path $OutputDir/$OutputFileName)
{
Remove-Item $OutputDir/$OutputFileName
}
#Test vars are picked up from the environment variables. The test var needs to be prefixed with "Test." then the name of the var
[Environment]::SetEnvironmentVariable("Test.publicwww",$PublicUrl)
& "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Mstest.exe" /TestContainer:"$WebTestPath" /resultsfile:"$OutputDir/$OutputFileName" /detail:errormessage /detail:outcometext /detail:duration /usestderr
@lawrencegripper
Copy link
Author

Sure don't see why not, you should be able to invoke it with Process.Start or similar but I haven't tried so wouldn't be able to give you guidance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment