Giter Site home page Giter Site logo

pester / vscode-adapter Goto Github PK

View Code? Open in Web Editor NEW
55.0 3.0 12.0 1.06 MB

Run PowerShell Pester Tests with Visual Studio Code

License: MIT License

PowerShell 28.22% TypeScript 71.54% JavaScript 0.25%
vscode vscode-extension testing visual-studio-code pester powershell scripts test hacktoberfest

vscode-adapter's Introduction

Pester

💵 Please consider sponsoring nohwnd, fflaten or sponsoring Pester itself.

🌵 Documentation is available at https://pester.dev/docs/quick-start.

📦🔐 Pester is now signed. -SkipPublisherCheck should no longer be used to install from PowerShell Gallery on Windows 10.

👩👨 We are looking for contributors! All issues labeled help wanted are up for grabs. They further split up into good first issue that are issues I hope are easy to solve. Bad first issue where I expect the implementation to be problematic or needs to be proposed and discussed beforehand. And the rest which is somewhere in the middle. If you decide to pick up an issue please comment in the issue thread so others don't waste their time working on the same issue as you. There is also contributor's guide that will hopefully help you.

Pester is the ubiquitous test and mock framework for PowerShell.

BeforeAll {
    # your function
    function Get-Planet ([string]$Name='*')
    {
        $planets = @(
            @{ Name = 'Mercury' }
            @{ Name = 'Venus'   }
            @{ Name = 'Earth'   }
            @{ Name = 'Mars'    }
            @{ Name = 'Jupiter' }
            @{ Name = 'Saturn'  }
            @{ Name = 'Uranus'  }
            @{ Name = 'Neptune' }
        ) | foreach { [PSCustomObject]$_ }

        $planets | where { $_.Name -like $Name }
    }
}

# Pester tests
Describe 'Get-Planet' {
  It "Given no parameters, it lists all 8 planets" {
    $allPlanets = Get-Planet
    $allPlanets.Count | Should -Be 8
  }

  Context "Filtering by Name" {
    It "Given valid -Name '<Filter>', it returns '<Expected>'" -TestCases @(
      @{ Filter = 'Earth'; Expected = 'Earth' }
      @{ Filter = 'ne*'  ; Expected = 'Neptune' }
      @{ Filter = 'ur*'  ; Expected = 'Uranus' }
      @{ Filter = 'm*'   ; Expected = 'Mercury', 'Mars' }
    ) {
      param ($Filter, $Expected)

      $planets = Get-Planet -Name $Filter
      $planets.Name | Should -Be $Expected
    }

    It "Given invalid parameter -Name 'Alpha Centauri', it returns `$null" {
      $planets = Get-Planet -Name 'Alpha Centauri'
      $planets | Should -Be $null
    }
  }
}

Save this code example in a file named Get-Planet.Tests.ps1, and run Invoke-Pester Get-Planet.Tests.ps1, or just press F5 in VSCode.

Learn how to start quick with Pester in our docs.

The example above also has an annotated and production ready version here.

Installation

Pester runs on Windows, Linux, MacOS and anywhere else thanks to PowerShell. It is compatible with Windows PowerShell 3, 4, 5, 6 and 7.

Pester 3 comes pre-installed with Windows 10, but we recommend updating, by running this PowerShell command as administrator:

Install-Module -Name Pester -Force

Not running Windows 10 or facing problems? See the full installation and update guide.

Features

Test runner

Pester runs your tests and prints a nicely formatted output to the screen.

test run output

Command line output is not the only output option, Pester also integrates with Visual Studio Code, Visual Studio, and any tool that can consume nUnit XML output.

Assertions

Pester comes with a suite of assertions that cover a lot of common use cases. Pester assertions range from very versatile, like Should -Be, to specialized like Should -Exists. Here is how you ensure that a file exists:

Describe 'Notepad' {
    It 'Exists in Windows folder' {
        'C:\Windows\notepad.exe' | Should -Exist
    }
}

Learn more about assertions in our documentation.

Mocking

Pester has mocking built-in. Using mocks you can easily replace functions with empty implementation to avoid changing the real environment.

function Remove-Cache {
    Remove-Item "$env:TEMP\cache.txt"
}

Describe 'Remove-Cache' {
    It 'Removes cached results from temp\cache.text' {
        Mock -CommandName Remove-Item -MockWith {}

        Remove-Cache

        Should -Invoke -CommandName Remove-Item -Times 1 -Exactly
    }
}

Learn more about Mocking here.

Code coverage

Pester can measure how much of your code is covered by tests and export it to JaCoCo format that is easily understood by build servers.

JaCoCo code coverage report

Learn more about code coverage here.

Build server integration

Pester integrates nicely with TFS, AppVeyor, TeamCity, Jenkins and other CI servers.

Testing your scripts, and all pull requests on AppVeyor is extremely simple. Just commit this appveyor.yml file to your repository, and select your repository on the AppVeyor website:

version: 1.0.{build}
image:
  - Visual Studio 2017
  - Ubuntu
install:
  - ps: Install-Module Pester -Force -Scope CurrentUser
build: off
test_script:
  - ps: Invoke-Pester -EnableExit

See it in action here! If you do not need to test your scripts against PowerShell Core, just simply remove the entire line mentioning Ubuntu.

Pester itself is built on AzureDevOps, and distributed mainly via PowerShell gallery.

Build Status latest version downloads

Further reading

Do you like what you see? Learn how to use Pester with our quick start guide.

Got questions?

Got questions or you just want to get in touch? Use our issues page or one of these channels:

Pester Twitter Pester on StackOverflow Testing channel on Powershell Slack Testing channel on Powershell Discord or try github discussions GitHub discussions.

Sponsored by

Pester is sponsored by Octopus Deploy.

Octopus deploy

As well as all the great folks on OpenCollective and GitHub.

Contributors

Code Contributors

This project exists thanks to all the people who contribute. Contribute code.

Financial Contributors on Open Collective

Become a financial contributor and help us sustain our community. Contribute to Pester Open Collective.

Individuals

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. Contribute

vscode-adapter's People

Contributors

antoinemartin avatar dependabot[bot] avatar johlju avatar justingrote avatar nohwnd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vscode-adapter's Issues

Powershell 5.1 has different test IDs if unicode is used

This is only an issue if you swap between PS7 and PS5.1 in the middle of a session, the tests will no longer identify.

Ways to fix:

  • Maybe base64 the IDs
  • Rediscover all tests if it gets switched and prepend with the exePath, this would allow different tests for different runners.

Many errors if there are `-ForEach` param

I see many errors for there test fragment:

Describe 'Open Document template' {
	Describe '<Name>' -ForEach @(
		$DestinationTemplateFile | Get-Item |
		ForEach-Object { @{ Name = $_.Name; FullName = $_.FullName } }
	) {
		It 'is valid (by ODFValidator)' {
			{
				java -D"file.encoding=UTF-8" -jar $ODFValidatorJarPath -e -w $FullName
				if ( $LASTEXITCODE -ne 0 )
				{
					Write-Error -Message 'Validation failed!' -ErrorAction 'Stop';
				};
			} | Should -Not -Throw
		}
	}
}

All test passed. But i see in console:

Starting discovery in 1 files.
Discovery found 1 tests in 243ms.
Running tests.
[-] Describe Open Document template.<Name> failed
 RuntimeException: Unsupported level out output 'c:\Users\sergei.s.betke\Documents\DocTemplates\tests\template\.Tests.ps1'
 в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 13191
 в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 2007
 в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 1949
 в Invoke-ScriptBlock, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 2113
 в Invoke-TestItem, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 1225
 в Invoke-Block, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 826
 в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 881
 в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 1988
 в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 1949
 в Invoke-ScriptBlock, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 2113
 в Invoke-Block, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 928
 в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 881
 в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 1988
 в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 1949
 в Invoke-ScriptBlock, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 2113
 в Invoke-Block, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 928
 в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 881
 в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 1988
 в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 1949
 в Invoke-ScriptBlock, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 2113
 в Invoke-Block, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 928
 в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 1662
 в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.ps1: строка 3
 в <ScriptBlock>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 3154
 в Invoke-InNewScriptScope, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 3161 в Run-Test, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 1665
 в Invoke-Test, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 2465
 в Invoke-Pester<End>, C:\Users\sergei.s.betke\Documents\WindowsPowerShell\Modules\Pester\5.3.0\Pester.psm1: строка 5225
 в Invoke-Main, C:\Users\sergei.s.betke\.vscode\extensions\pspester.pester-test-0.0.3\Scripts\PesterInterface.ps1: строка 392 в <ScriptBlock>, C:\Users\sergei.s.betke\.vscode\extensions\pspester.pester-test-0.0.3\Scripts\PesterInterface.ps1: строка 396
 в <ScriptBlock>, <Нет файла>: строка 1
Tests completed in 3.06s
Tests Passed: 1, Failed: 0, Skipped: 0 NotRun: 0
BeforeAll \ AfterAll failed: 1
  - Open Document template.<Name>
PS C:\Users\sergei.s.betke\Documents\DocTemplates>

If multiple Pester modules are loaded into the session `Get-DurationString` fails

When multiple version of Pester is imported into the session from different locations the function Get-DurationString fails.

Path : C:\Users\johan.ljunggren\Documents\PowerShell\Modules\Pester\5.3.0\Pester.psm1

Path : C:\source\FileSystemDsc\output\RequiredModules\Pester\5.3.0\Pester.psm1
[-] Context DSC_FileSystemAccessRule\Set-TargetResource.When the system is not in the desired state.When the access rules fails to be set failed
 CommandNotFoundException: The term 'Pester Pester' is not recognized as a name of a cmdlet, function, script file, or executable program.
 Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
 at Get-DurationString, C:\Users\johan.ljunggren\.vscode\extensions\pspester.pester-test-0.0.3\Scripts\PesterInterface.ps1:200
 at New-TestObject, C:\Users\johan.ljunggren\.vscode\extensions\pspester.pester-test-0.0.3\Scripts\PesterInterface.ps1:244
 at <ScriptBlock>, C:\Users\johan.ljunggren\.vscode\extensions\pspester.pester-test-0.0.3\Scripts\PesterInterface.ps1:326

MultiplePester

I think this line should get the highest version of Pester that is imported into the session - if multiple exist with the same version then it should return the same.

$p = Get-Module Pester

Maybe change to:

Get-Module Pester | Sort-Object version -Descending | Select -First 1

Tests pane doesn't show up for my projects

After some time of successfully usage of this extension, I've started experiencing an issue where the Testing panel stopped showing up. While digging through the Logs (Extension Host) I've noticed the following line (for a session when I have my project opened):

[2021-12-15 22:40:26.699] [exthost] [info] Not activating extension 'pspester.pester-test': Timed out while searching for 'workspaceContains' pattern **/*.[tT]ests.[pP][sS]1

Any idea of how to fix that?

There are actually a few other extensions that also timeout in the same fashion:

[2021-12-15 23:14:50.580] [exthost] [info] Not activating extension 'ms-azuretools.vscode-azurefunctions': Timed out while searching for 'workspaceContains' pattern **/host.json
[2021-12-15 23:14:50.580] [exthost] [info] Not activating extension 'ms-dotnettools.csharp': Timed out while searching for 'workspaceContains' pattern *.csproj,*.sln,*.slnf,*.csx,*.cake,**/*.csproj,**/*.sln,**/*.slnf,**/*.csx,**/*.cake

Thanks!

Feature Request: Add a "Pause" Button in Test Explorer bar

Hi,
Thanks a lot for this great extension.
I think it would be practical to add a "Pause" button that will stop discovery, stop autorun on save.
Even if there is the setting pester.autoRunOnsave , this button will allow more dynamic interaction between code change and tests Runs.

My scenario is that during the conversion of pester v4 to pester v5 , this extension run the v4 tests and I would prefer to pause theses tests during the conversion time.
Thank you for your time on this.
image

♻️ Pester run pipeline

Firm up the Pester test types for the final API and optimize for async operations.

Primarily, Pester is not very efficient unless you run as many tests as you can together, so we want to take runhandler requests and queue them with a timer, and then execute once the timer expires

🐛 5.1 Compatability: Will fail on unicode characters in test names

If a unicode character (e.g. emoji) is present in 5.1, it will fail the pester test discovery. This should probably be opened as a downstream pester issue instead and advice will be to use 7 if you want emojis in your test names.

Invoke-pester -Configuration $config

Connecting to pipe PesterTestController-7976
Discovery: Starting test discovery in 1 test containers. 

Starting discovery in 1 files.
Discovery: Discovering tests in C:\Users\JGrote\Projects\vscode-adapter\sample\Tests\Basic.Tests.ps1 
Discovering in C:\Users\JGrote\Projects\vscode-adapter\sample\Tests\Basic.Tests.ps1.
[-] Discovery in C:\Users\JGrote\Projects\vscode-adapter\sample\Tests\Basic.Tests.ps1 failed with:
System.Management.Automation.ParseException: At 
C:\Users\JGrote\Projects\vscode-adapter\sample\Tests\Basic.Tests.ps1:48 char:51
+     @{ Name = 'giraffe'; Symbol = '🦒'; Kind = 'Animal' }
+                                                   ~~~~~~~~~
Unexpected token 'Animal' }
) {
    It 'Returns' in expression or statement.

At C:\Users\JGrote\Projects\vscode-adapter\sample\Tests\Basic.Tests.ps1:48 char:51

🙏 Feature Request: AST-Based Test Discovery that doesn't run test discovery logic

It's related probably to: TylerLeonhardt/vscode-pester-test-adapter#16

autoexecute

PS C:\Support\GitHub\GpoZaurr> . 'c:\Users\przemyslaw.klys\.vscode\extensions\pspester.pester-test-0.0.1\Scripts\PesterInterface.ps1' -Discovery -PipeName PesterTestController-17564 c:\Support\GitHub\GpoZaurr\Tests\GPOPermissions.Tests.ps1 -Verbosity None
Import-Module : The value Ignore is not supported for an ActionPreference variable. The provided value sh
ould be used only as a value for a preference parameter, and has been replaced by the default value. For
more information, see the Help topic, "about_Preference_Variables."
At C:\Users\przemyslaw.klys\.vscode\extensions\pspester.pester-test-0.0.1\Scripts\PesterInterface.ps1:337
 char:15
+     $Pester = Import-Module Pester -PassThru
+               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Import-Module], NotSupportedException
    + FullyQualifiedErrorId : System.NotSupportedException,Microsoft.PowerShell.Commands.ImportModuleCom
   mand

The expression after '&' in a pipeline element produced an object that was not valid. It must result in a
 command name, a script block, or a CommandInfo object.
At C:\Users\przemyslaw.klys\.vscode\extensions\pspester.pester-test-0.0.1\Scripts\PesterInterface.ps1:338
 char:7
+     & $Pester {
+       ~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : BadExpression

And

PS C:\Support\GitHub\GpoZaurr> . 'c:\Users\przemyslaw.klys\.vscode\extensions\pspester.pester-test-0.0.1\Scripts\PesterInterface.ps1' -Discovery -PipeName PesterTestController-17564 c:\Support\GitHub\GpoZaurr\GPOZaurr.Tests.ps1 -Verbosity None
Import-Module : The value Ignore is not supported for an ActionPreference variable. The provided value sh
ould be used only as a value for a preference parameter, and has been replaced by the default value. For
more information, see the Help topic, "about_Preference_Variables."
At C:\Users\przemyslaw.klys\.vscode\extensions\pspester.pester-test-0.0.1\Scripts\PesterInterface.ps1:337
 char:15
+     $Pester = Import-Module Pester -PassThru
+               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Import-Module], NotSupportedException
    + FullyQualifiedErrorId : System.NotSupportedException,Microsoft.PowerShell.Commands.ImportModuleCom
   mand

The expression after '&' in a pipeline element produced an object that was not valid. It must result in a
 command name, a script block, or a CommandInfo object.
At C:\Users\przemyslaw.klys\.vscode\extensions\pspester.pester-test-0.0.1\Scripts\PesterInterface.ps1:338
 char:7
+     & $Pester {
+       ~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : BadExpression



ModuleName: GPOZaurr Version: 0.0.129
PowerShell Version: 5.1.19041.1151
PowerShell Edition: Desktop
Required modules: 
   [>] PSSharedGoods Version: 0.0.208
   [>] ADEssentials Version: 0.0.130
   [>] PSWriteHTML Version: 0.0.158
   [>] CimCmdlets
   [>] Microsoft.PowerShell.Management
   [>] Microsoft.PowerShell.Utility
   [>] Microsoft.PowerShell.Security

Import-Module : The value Ignore is not supported for an ActionPreference variable. The provided value sh
ould be used only as a value for a preference parameter, and has been replaced by the default value. For
more information, see the Help topic, "about_Preference_Variables."
At C:\Support\GitHub\GpoZaurr\GPOZaurr.Tests.ps1:46 char:1
+ Import-Module $PSScriptRoot\*.psd1 -Force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Import-Module], NotSupportedException
    + FullyQualifiedErrorId : System.NotSupportedException,Microsoft.PowerShell.Commands.ImportModuleCom
   mand

Export-ModuleMember : The value Ignore is not supported for an ActionPreference variable. The provided va
lue should be used only as a value for a preference parameter, and has been replaced by the default value
. For more information, see the Help topic, "about_Preference_Variables."
At C:\Users\przemyslaw.klys\Documents\WindowsPowerShell\Modules\Pester\5.1.1\Pester.psm1:15353 char:1
+ & $script:SafeCommands['Export-ModuleMember'] @(
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Export-ModuleMember], NotSupportedException
    + FullyQualifiedErrorId : System.NotSupportedException,Microsoft.PowerShell.Commands.ExportModuleMem
   berCommand

Is there a way to change the startup directory for the PowerShell process?

It seems the current startup directory is the VSCode app directory ($Env:LocalAppData\Programs\Microsoft VS Code in Windows). Is there a way to set it, for example, to the VSCode workspace folder (${workspaceFolder})?

I know there is $PSScriptRoot to reference the current test file's directory, but there seems to be no straight forward/consistent way to reference the workspace root (directory).

Normalize all Windows paths to uppercase

On Windows, javascript and powershell format paths differently, leading to ID mismatch issues. Normalize to uppercase since it is case insensitive on windows.

Fails to expand tests in test explorer on macOS

When trying to expand tests on macOS it fails with errors:

PS /Users/johlju/source/SqlServerDsc> . '/Users/johlju/.vscode/extensions/pspester.pester-test-0.0.2/Scripts/PesterInterface.ps1' -Discovery -PipeName PesterTestController-85984 /Users/johlju/source/SqlServerDsc/tests/Unit/DSC_SqlAgentAlert.Tests.ps1 -Verbosity None
Connecting to pipe PesterTestController-85984
Invoking step Start failed:
Result :Error :
MethodInvocationException: /Users/johlju/.vscode/extensions/pspester.pester-test-0.0.2/Scripts/PesterInterface.ps1:295:9
Line |
 295 |          $__TestAdapterNamedPipeClient.Connect(5000)
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Exception calling "Connect" with "1" argument(s): "The operation has timed out."

at <ScriptBlock>, /Users/johlju/.vscode/extensions/pspester.pester-test-0.0.2/Scripts/PesterInterface.ps1: line 295
at Invoke-PluginStep, /Users/johlju/source/SqlServerDsc/output/RequiredModules/Pester/5.2.2/Pester.psm1: line 1750
at Invoke-Pester<End>, /Users/johlju/source/SqlServerDsc/output/RequiredModules/Pester/5.2.2/Pester.psm1: line 5080
at Invoke-Main, /Users/johlju/.vscode/extensions/pspester.pester-test-0.0.2/Scripts/PesterInterface.ps1: line 386
at <ScriptBlock>, /Users/johlju/.vscode/extensions/pspester.pester-test-0.0.2/Scripts/PesterInterface.ps1: line 445
at <ScriptBlock>, <No file>: line 1

System.Management.Automation.RuntimeException: Invoking step Start failed:
Result :Error :
MethodInvocationException: /Users/johlju/.vscode/extensions/pspester.pester-test-0.0.2/Scripts/PesterInterface.ps1:295:9
Line |
 295 |          $__TestAdapterNamedPipeClient.Connect(5000)
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Exception calling "Connect" with "1" argument(s): "The operation has timed out."

at <ScriptBlock>, /Users/johlju/.vscode/extensions/pspester.pester-test-0.0.2/Scripts/PesterInterface.ps1: line 295
at Invoke-PluginStep, /Users/johlju/source/SqlServerDsc/output/RequiredModules/Pester/5.2.2/Pester.psm1: line 1750
at Invoke-Pester<End>, /Users/johlju/source/SqlServerDsc/output/RequiredModules/Pester/5.2.2/Pester.psm1: line 5080
at Invoke-Main, /Users/johlju/.vscode/extensions/pspester.pester-test-0.0.2/Scripts/PesterInterface.ps1: line 386
at <ScriptBlock>, /Users/johlju/.vscode/extensions/pspester.pester-test-0.0.2/Scripts/PesterInterface.ps1: line 445
at <ScriptBlock>, <No file>: line 1

at Assert-Success, /Users/johlju/source/SqlServerDsc/output/RequiredModules/Pester/5.2.2/Pester.psm1: line 1808
at Invoke-PluginStep, /Users/johlju/source/SqlServerDsc/output/RequiredModules/Pester/5.2.2/Pester.psm1: line 1769
at Invoke-Pester<End>, /Users/johlju/source/SqlServerDsc/output/RequiredModules/Pester/5.2.2/Pester.psm1: line 5080
at Invoke-Main, /Users/johlju/.vscode/extensions/pspester.pester-test-0.0.2/Scripts/PesterInterface.ps1: line 386
at <ScriptBlock>, /Users/johlju/.vscode/extensions/pspester.pester-test-0.0.2/Scripts/PesterInterface.ps1: line 445
at <ScriptBlock>, <No file>: line 1

Adapter won't work if path to VSCode has spaces.

Here is log from Pester Output panel:

22:08:11.248 INFO [dt.resolveHandler] Initializing Pester Test Controller and watching for Pester Files 
22:08:11.560 INFO [dt.watchWorkspaces] Detected Pester File:  d:\Temp\TestsWithPester\Tests\TestsWithPester.Tests.ps1 
22:08:17.008 DEBUG [undefined.<anonymous>] Run invoked on undiscovered testFile TestsWithPester.Tests.ps1, discovery will be run first 
22:08:17.012 DEBUG [dt.resolveHandler] Adding to Discovery Queue:  D:\TEMP\TESTSWITHPESTER\TESTS\TESTSWITHPESTER.TESTS.PS1 
22:08:17.118 INFO [dt.<anonymous>] Starting Test Discovery of 1 files 
22:08:17.144 INFO [dt.startPesterInterface] Starting PowerShell testing instance: C:\Program Files\PowerShell\7\pwsh.exe 
22:08:17.147 DEBUG [dt.startPesterInterface] Running Script in PS Worker: & 'D:\Visual Studio Code\data\extensions\pspester.pester-test-2021.9.1\Scripts\PesterInterface.ps1' -Discovery 'd:\Temp\TestsWithPester\Tests\TestsWithPester.Tests.ps1' 

It hangs after the last line and nothing (visible) happens.

Here is a capture from VSCode:

Animation

If I click on 'Run Pester Tests' in Context Menu of TestsWithPester.Tests.ps1 Tab then tests are executed just fine without any output in Pester Panel.

Pester Tester v2021.9.1
Pester 5.3.1
Powershell Core 7.1.4

How I can see test log from tests tree?

My example:

Describe 'Open Document template' {
	Describe '<Name>' -ForEach @(
		$DestinationTemplateFile | Get-Item |
		ForEach-Object { @{ Name = $_.Name; FullName = $_.FullName } }
	) {
		It 'is valid (by ODFValidator)' {
			{
				java -D"file.encoding=UTF-8" -jar $ODFValidatorJarPath -e -w $FullName
				if ( $LASTEXITCODE -ne 0 )
				{
					Write-Error -Message 'Validation failed!' -ErrorAction 'Stop';
				};
			} | Should -Not -Throw
		}
	}
}

One test failed. How I can see test output from test tree?

Running tests gives error `Unsupported level out output`

When expanding the tests for file DSC_SqlAgentAlert.Tests.ps1 then running the tests for the entire file each test (using "Run Test") fails with an error message Unsupported level out output. That is not shown when running in "Debug Test".

Build succeeded. 1 tasks, 0 errors, 0 warnings 00:00:03.3297802
C:\source\SqlServerDsc [f/support-pester-5 ≡ +0 ~3 -0 !]> . 'c:\Users\johan.ljunggren\.vscode\extensions\pspester.pester-test-0.0.2\Scripts\PesterInterface.ps1' -Discovery -PipeName PesterTestController-35192 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1 -Verbosity None
Connecting to pipe PesterTestController-35192
C:\source\SqlServerDscPS> . 'c:\Users\johan.ljunggren\.vscode\extensions\pspester.pester-test-0.0.2\Scripts\PesterInterface.ps1' -PipeName PesterTestController-35192 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:46 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:90 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:97 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:114 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:124 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:136 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:147 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:157 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:162 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:172 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:184 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:198 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:204 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:218 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:219 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:233 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:253 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:267 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:286 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:300 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:317 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:336 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:337 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:351 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:368 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:382 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:400 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:418 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:432 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:452 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:576 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:583 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:603 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:611 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:631 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:646 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:661 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:677 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:692 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:707 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:722 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:737 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:764 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:769 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:774 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:790 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:817
Connecting to pipe PesterTestController-35192

Starting discovery in 1 files.
Discovery finished in 36ms.
Running tests.
[-] Context DSC_SqlAgentAlert\Get-TargetResource.When Connect-SQL returns nothing failed
 RuntimeException: Unsupported level out output 'c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1'

[-] Context DSC_SqlAgentAlert\Get-TargetResource.When the system is not in the desired state failed
 RuntimeException: Unsupported level out output 'c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1'

[-] Context DSC_SqlAgentAlert\Get-TargetResource.When the system is in the desired state for a sql agent alert failed
 RuntimeException: Unsupported level out output 'c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1'

[-] Context DSC_SqlAgentAlert\Test-TargetResource.When the system is not in the desired state.When the alert does not exist failed
 RuntimeException: Unsupported level out output 'c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1'

[-] Context DSC_SqlAgentAlert\Test-TargetResource.When the system is not in the desired state.When the alert should not exist failed
 RuntimeException: Unsupported level out output 'c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1'

[-] Context DSC_SqlAgentAlert\Test-TargetResource.When the system is not in the desired state.When enforcing a severity alert failed
 RuntimeException: Unsupported level out output 'c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1'

[-] Context DSC_SqlAgentAlert\Test-TargetResource.When the system is in the desired state.When an alert does not exist failed
 RuntimeException: Unsupported level out output 'c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1'

[-] Context DSC_SqlAgentAlert\Test-TargetResource.When the system is in the desired state.When enforcing a severity alert failed
 RuntimeException: Unsupported level out output 'c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1'

[-] Context DSC_SqlAgentAlert\Test-TargetResource.When the system is in the desired state.When enforcing a message alert failed
 RuntimeException: Unsupported level out output 'c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1'

[-] Context DSC_SqlAgentAlert\Set-TargetResource.When Connect-SQL returns nothing failed
 RuntimeException: Unsupported level out output 'c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1'

[-] Context DSC_SqlAgentAlert\Set-TargetResource.When the system is not in the desired state and Ensure is set to Present failed
 RuntimeException: Unsupported level out output 'c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1'

[-] Context DSC_SqlAgentAlert\Set-TargetResource.When the system is not in the desired state and Ensure is set to Absent failed
 RuntimeException: Unsupported level out output 'c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1'

Tests completed in 1.5s
Tests Passed: 12, Failed: 18, Skipped: 0 NotRun: 0
BeforeAll \ AfterAll failed: 12
  - DSC_SqlAgentAlert\Get-TargetResource.When Connect-SQL returns nothing
  - DSC_SqlAgentAlert\Get-TargetResource.When the system is not in the desired state
  - DSC_SqlAgentAlert\Get-TargetResource.When the system is in the desired state for a sql agent alert
  - DSC_SqlAgentAlert\Test-TargetResource.When the system is not in the desired state.When the alert does not exist
  - DSC_SqlAgentAlert\Test-TargetResource.When the system is not in the desired state.When the alert should not exist
  - DSC_SqlAgentAlert\Test-TargetResource.When the system is not in the desired state.When enforcing a severity alert
  - DSC_SqlAgentAlert\Test-TargetResource.When the system is in the desired state.When an alert does not exist
  - DSC_SqlAgentAlert\Test-TargetResource.When the system is in the desired state.When enforcing a severity alert
  - DSC_SqlAgentAlert\Test-TargetResource.When the system is in the desired state.When enforcing a message alert
  - DSC_SqlAgentAlert\Set-TargetResource.When Connect-SQL returns nothing
  - DSC_SqlAgentAlert\Set-TargetResource.When the system is not in the desired state and Ensure is set to Present
  - DSC_SqlAgentAlert\Set-TargetResource.When the system is not in the desired state and Ensure is set to Absent

When running the same test with "Debug Test" they pass correctly:

...

Mock: Behavior for DSC_SqlAgentAlert - Connect-SQL was executed. 
   [+] Should throw the correct error when Drop() method was called with invalid operation 82ms (77ms|5ms)
Mock: Getting all verifiable mock behaviors in this scope. 
Mock: We are in a test. Finding all behaviors in this test. 
   [+] Should call all verifiable mocks 20ms (15ms|6ms)
Mock: Removing function PesterMock_DSC_SqlAgentAlert_Connect-SQL_22f17be4-aa07-4dce-9263-f5d9f52a3de2 and aliases Connect-SQL, SqlServerDsc.Common\Connect-SQL for Connect-SQL. 
Mock: Removed function PesterMock_DSC_SqlAgentAlert_Connect-SQL_22f17be4-aa07-4dce-9263-f5d9f52a3de2 from module DSC_SqlAgentAlert session state. 
Mock: Removed alias Connect-SQL from module DSC_SqlAgentAlert session state. 
Mock: Removed alias SqlServerDsc.Common\Connect-SQL from module DSC_SqlAgentAlert session state. 
Tests completed in 4.4s
Tests Passed: 30, Failed: 0, Skipped: 0 NotRun: 0

Errors in BeforeAll/AfterAll are not reflected in the UI

Consider the following test file:

BeforeAll {
  Write-Error "Stop!!!" -ErrorAction 'Stop'
}

Context 'Context' {
  It '$True is $True' { $True | Should -BeExactly $True }
  It '$False is $False' { $False | Should -BeExactly $False }
}

The UI (gutter icons, test explorer) looks like the tests were evaluated (the previous passed/failed states reappear), while only the 'Test Output' in the terminal indicates the error.

Update icon if possible

Hi VS Code PM here 👋

We decided to make your extension featured this month https://marketplace.visualstudio.com/vscode
The issue is that the Marketplace site does not render your icon nicely, since it is very white. Thus the list looks a bit broken.

I was wondering if it would be possible to update the icon so it looks better in the list?
If this is not possible no problem. We will fix the rendering on our side in the future and we can then feature your extension.

Thanks a lot
Isidor

A new setting to run a PowerShell command in the same process before first discovery

When running tests in a PowerShell module project based on the Sampler project (or similar tools) there is a need to run build.ps1 prior to running any tests. The build.ps1 sets up the PowerShell session with the correct path to modules in $env:PSModulePath etc.

Suggest adding a setting that takes a path that is run the first time in each new session, before first discovery.

In our case the setting would hold ./build.ps1 -Task noop

Pester Test Adapter should error if Pester is not Installed

Trying to expand in test explorer and Pester is not available to the session makes that test no longer able to expand. When Pester is available (running build.ps1 in this case) clicking on another test it tries to expands.

Everything is a bit slow since I have the code on /mnt/c.

FailsOnMissingPester

When running an individual test it tries to run all test

When choosing "Run Test" from the individual test "list" (first play symbol):

image

it tries to run all found tests

image

If choosing the second "play button" called "Debug Test" the individual test run as expected.

FYI, it stops and asks for MainGitBranch because it runs a test that is not part of the project, a test that requires parameters to run. See issue #20.

When starting up VS Code the status of tests are remembered

After tests has run and in this case passed, it is reported as passed in test explorer (marked green). When restarting Visual Studio Code the green indicator is still present, and expanding the test file in test explorer the green mark is also added to the code file (if made visible using "Go To Test"). This is even if there has been code changes to the test that is marked green.

Suggest making all test to have "not run" indicator when starting VS Code. Otherwise it could give the impression that the test works with new code changes, even though the test was never run with those new code changes.

Cannot run\discover tests when there are space characters in the path

Hi,

I've noticed that it if the path to my .Tests.ps1 files contain space characters.

As far as I understand, the issue us caused by the fact that the path to the script file is provided to PesterInterface.ps1 script without being wrapped into quotes, which leads the script to misinterpret the path value.

I'm not so good with TypeScript, but I think that the problem can be fixed here (by appending quotes on the both ends of testLine):

Reports status passed even if the test failed

When expanding the tests for file DSC_SqlAgentAlert.Tests.ps1 then running the tests for the entire file each test (using "Run Test") fails with an error message, that is not shown when running in "Debug Test", so that is probably another issue. Though, I wasn't expecting it to report all test as passed. 🙂

Build succeeded. 1 tasks, 0 errors, 0 warnings 00:00:03.3297802
C:\source\SqlServerDsc [f/support-pester-5 ≡ +0 ~3 -0 !]> . 'c:\Users\johan.ljunggren\.vscode\extensions\pspester.pester-test-0.0.2\Scripts\PesterInterface.ps1' -Discovery -PipeName PesterTestController-35192 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1 -Verbosity None
Connecting to pipe PesterTestController-35192
C:\source\SqlServerDscPS> . 'c:\Users\johan.ljunggren\.vscode\extensions\pspester.pester-test-0.0.2\Scripts\PesterInterface.ps1' -PipeName PesterTestController-35192 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:46 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:90 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:97 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:114 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:124 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:136 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:147 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:157 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:162 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:172 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:184 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:198 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:204 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:218 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:219 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:233 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:253 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:267 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:286 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:300 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:317 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:336 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:337 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:351 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:368 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:382 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:400 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:418 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:432 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:452 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:576 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:583 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:603 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:611 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:631 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:646 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:661 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:677 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:692 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:707 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:722 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:737 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:764 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:769 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:774 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:790 c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1:817
Connecting to pipe PesterTestController-35192

Starting discovery in 1 files.
Discovery finished in 36ms.
Running tests.
[-] Context DSC_SqlAgentAlert\Get-TargetResource.When Connect-SQL returns nothing failed
 RuntimeException: Unsupported level out output 'c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1'

[-] Context DSC_SqlAgentAlert\Get-TargetResource.When the system is not in the desired state failed
 RuntimeException: Unsupported level out output 'c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1'

[-] Context DSC_SqlAgentAlert\Get-TargetResource.When the system is in the desired state for a sql agent alert failed
 RuntimeException: Unsupported level out output 'c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1'

[-] Context DSC_SqlAgentAlert\Test-TargetResource.When the system is not in the desired state.When the alert does not exist failed
 RuntimeException: Unsupported level out output 'c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1'

[-] Context DSC_SqlAgentAlert\Test-TargetResource.When the system is not in the desired state.When the alert should not exist failed
 RuntimeException: Unsupported level out output 'c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1'

[-] Context DSC_SqlAgentAlert\Test-TargetResource.When the system is not in the desired state.When enforcing a severity alert failed
 RuntimeException: Unsupported level out output 'c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1'

[-] Context DSC_SqlAgentAlert\Test-TargetResource.When the system is in the desired state.When an alert does not exist failed
 RuntimeException: Unsupported level out output 'c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1'

[-] Context DSC_SqlAgentAlert\Test-TargetResource.When the system is in the desired state.When enforcing a severity alert failed
 RuntimeException: Unsupported level out output 'c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1'

[-] Context DSC_SqlAgentAlert\Test-TargetResource.When the system is in the desired state.When enforcing a message alert failed
 RuntimeException: Unsupported level out output 'c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1'

[-] Context DSC_SqlAgentAlert\Set-TargetResource.When Connect-SQL returns nothing failed
 RuntimeException: Unsupported level out output 'c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1'

[-] Context DSC_SqlAgentAlert\Set-TargetResource.When the system is not in the desired state and Ensure is set to Present failed
 RuntimeException: Unsupported level out output 'c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1'

[-] Context DSC_SqlAgentAlert\Set-TargetResource.When the system is not in the desired state and Ensure is set to Absent failed
 RuntimeException: Unsupported level out output 'c:\source\SqlServerDsc\tests\Unit\DSC_SqlAgentAlert.Tests.ps1'

Tests completed in 1.5s
Tests Passed: 12, Failed: 18, Skipped: 0 NotRun: 0
BeforeAll \ AfterAll failed: 12
  - DSC_SqlAgentAlert\Get-TargetResource.When Connect-SQL returns nothing
  - DSC_SqlAgentAlert\Get-TargetResource.When the system is not in the desired state
  - DSC_SqlAgentAlert\Get-TargetResource.When the system is in the desired state for a sql agent alert
  - DSC_SqlAgentAlert\Test-TargetResource.When the system is not in the desired state.When the alert does not exist
  - DSC_SqlAgentAlert\Test-TargetResource.When the system is not in the desired state.When the alert should not exist
  - DSC_SqlAgentAlert\Test-TargetResource.When the system is not in the desired state.When enforcing a severity alert
  - DSC_SqlAgentAlert\Test-TargetResource.When the system is in the desired state.When an alert does not exist
  - DSC_SqlAgentAlert\Test-TargetResource.When the system is in the desired state.When enforcing a severity alert
  - DSC_SqlAgentAlert\Test-TargetResource.When the system is in the desired state.When enforcing a message alert
  - DSC_SqlAgentAlert\Set-TargetResource.When Connect-SQL returns nothing
  - DSC_SqlAgentAlert\Set-TargetResource.When the system is not in the desired state and Ensure is set to Present
  - DSC_SqlAgentAlert\Set-TargetResource.When the system is not in the desired state and Ensure is set to Absent

image

Need a extension setting for choosing what paths to use to list test

When doing development for the repo SqlServerDsc we run

.\build.ps1 -ResolveDependency -Tasks build

that gives us a folder structure like the following (just the important parts listed):

C:\source
└───SqlServerDsc
    │   build.ps1
    │
    ├───output
    │   └───RequiredModules
    │   └───SqlServerDsc
    ├───source
    │
    └───tests
        └───QA
                module.tests.ps1
        └───Unit
        └───Integration

In the folder RequiredModules we have a lot of dependencies for the pipeline (among other things). The problem is that those modules in that folder contain a lot of tests that are also listed, but they are not part of the project.

The test from the red mark are not part of the SqlServerDsc project.
image

Suggest adding a extension settings for setting what paths are used for reading tests, e.g. ProjectTestFolders.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.