Skip to content
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

Single quotes inside Pester test names prevent tests from running #1725

Closed
sobjornstad opened this issue Jan 24, 2019 · 5 comments · Fixed by #1729
Closed

Single quotes inside Pester test names prevent tests from running #1725

sobjornstad opened this issue Jan 24, 2019 · 5 comments · Fixed by #1729
Labels

Comments

@sobjornstad
Copy link

sobjornstad commented Jan 24, 2019

Issue Description

The "Run Tests" or "Debug Tests" option appearing above Pester Describe blocks does not work when the string contains a single quote. vscode-powershell appears to be neglecting to escape them when issuing a shell command to run the tests.

Describe "This test works" {
    It "follows the basic principles of logic" {
        $true | should be $true
    }
}

Describe "This test's broken" {
    It "follows the basic principles of logic" {
        $true | should be $true
    }
}

Working test yields:

Describing This test works
 [+] follows the basic principles of logic 56ms
Tests completed in 56ms
Passed: 1 Failed: 0 Skipped: 0 Pending: 0 Inconclusive: 0

And broken test:

The string is missing the terminator: '.
At line:0 char:0

I'm still using version 3.4.0 of Pester, if that matters. The tests run fine when I call Invoke-Pester in the console.

Environment Information

Visual Studio Code

Name Version
Operating System Windows_NT x64 10.0.15063
VSCode 1.30.2
PowerShell Extension Version 1.10.2

PowerShell Information

Name Value
PSVersion 5.1.15063.1563
PSEdition Desktop
PSCompatibleVersions 1.0 2.0 3.0 4.0 5.0 5.1.15063.1563
BuildVersion 10.0.15063.1563
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Visual Studio Code Extensions

Visual Studio Code Extensions(Click to Expand)
Extension Author Version
PowerShell ms-vscode 1.10.2

(All other extensions manually disabled to confirm no interference)

@TylerLeonhardt
Copy link
Member

We're probably not escaping the string in the Describe block properly. Thanks for opening this!

@rkeithhill
Copy link
Contributor

Yup. Using line numbers to run/debug individual tests is looking better and better. :-)

@bergmeister
Copy link
Contributor

bergmeister commented Jan 26, 2019

PR #1713 will enable this scenario when the new Pester version 4.6.0 is installed but I also submitted PR #1729 to fix it for older Pester versions as well.

@AlexanderSehr
Copy link

One comment from my side: It's still possible to resolve this error if your test looks somewhat like this

It '[<moduleFolderName>] The template file should contain required elements: schema, contentVersion, resources' -TestCases $deploymentFolderTestCases {

After some trial and error it turned out the issue is the `' at the end of the test name.

If I add an artificatial space in the end it works:

It '[<moduleFolderName>] The template file should contain required elements: schema, contentVersion, resources ' -TestCases $deploymentFolderTestCases {

Fyi ;)

@ghost
Copy link

ghost commented Feb 3, 2023

Thank you for your comment, but please note that this issue has been closed for over a week. For better visibility, consider opening a new issue with a link to this instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants