Tool: Visual Studio 2019/2022 - Free and Pro Trial
Version: 2019 and 2022
Using PowerShell Tools For Visual Studio, I have a solution with a project with psm1 files, and another project with ps1 files that I use to run my Pester unit tests.
Tests are discovered by the Test Explorer, and I can run them, but they are really slow to execute when I compare to the time they take to execute in a command line, or in VSCode.
I tried different things:
- Updating Pester to the latest version in the default PowerShell
- Installing the latest PowerShell Core, and using the pro version to use that version in the tools.
But it still takes the same amount of time to execute.
Is there a different way to speed up the execution of pester unit tests in the Visual Studio?
At the moment my tests are declared in multiple ps1 files with 1 Describe by files, and multiple Contexts in those Describe, 1 Context per Methods tested, the multiple It for each methods:
Describe "Assembly" {
Context "GetAssemblyName" {
It "Should find the assembly name in every project file." {
CopyMasterFiles
$sol = "$(MasterfileTemp)\TestSolution"
foreach($projectFile in (MasterProjectFiles))
{
$projectFile = "$sol\$projectFile"
$projectName = Split-Path $projectFile -Leaf
$projectName = $projectName.Substring(0, $projectName.LastIndexOf('.'))
"$projectFile $(GetAssemblyName $projectFile)" | Should -Be "$projectFile $projectName"
}
WereMasterfilesTempered | Should -Be $false
}
It "Should work when provided a System.IO.FileInfo." {
CopyMasterFiles
$sol = "$(MasterfileTemp)\TestSolution"
foreach($projectFile in (MasterProjectFiles))
{
$projectFile = Get-Item "$sol\$projectFile"
$projectName = Split-Path $projectFile -Leaf
$projectName = $projectName.Substring(0, $projectName.LastIndexOf('.'))
"$projectFile $(GetAssemblyName $projectFile)" | Should -Be "$projectFile $projectName"
}
WereMasterfilesTempered | Should -Be $false
}
}