-
Notifications
You must be signed in to change notification settings - Fork 511
Add support for running Pester tests #87
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
Comments
I think @dfinke has done this before in VS Code. For now it just requires defining a task which can run Pester. To take it further, we could implement our own Pester harness (possibly in PowerShell Editor Services) which could integrate with VS Code in a couple interesting ways:
Could be an interesting feature to add! |
This has been partially addressed by PR #97, #98 and #105. However what we want is for VSCode to support creation of the tasks.json file with the Pester test task runner already configured in it rather than require the user to do that. See microsoft/vscode#2263 |
Looks like support for creation of the tasks.json file is supported. All that's left is to have the PowerShell extension create a test task that runs Pester. |
There's a great extension called Test Explorer UI, which is sort of a general "framework" for showing tests for a project. For each supported language, an adapter extension must be created, of which there currently are several: Jasmine Test Explorer, Mocha Test Explorer, .NET Core Test Explorer, just to name a few. I had a brief thought to create such an adapter for Pester specifically (I can't remember the Pester issue I commented on about this very thing.) |
@fourpastmidnight that would be awesome and would be a great addition to our ecosystem :) Someone recently did something similar with Code Coverage https://www.pwsh.site/powershell/2019/01/10/how-to-enable-coverage-markings-in-vscode-for-your-powershell-projects.html applying Pester to general purpose extensions. It's a great idea! |
https://code.visualstudio.com/api/references/contribution-points#contributes.taskDefinitions this link shows how to define your own custom tasks |
@TylerLeonhardt this one may be closeable, I don't know if there's anything that needs to be done in the extension itself vs. testing-specific extensions or tasks, not sure if it's really in the scope of this extension specifically. |
The intent with this one was to have a command to add a "run Pesters tests" task to the workspace's tasks.json file. While being able to use the code lens feature is nice, if you have a lot of script files it isn't so convenient to run all the Pester tests in the workspace. Hence, I have a task in my projects to run all the project's Pester tests. |
@rkeithhill You can now have "global" tasks in your user settings, I have this in mine: "launch": {
"compounds": [],
"configurations": [
{
"name": "PowerShell: Interactive",
"request": "launch",
"type": "PowerShell"
},
{
"args": [
"${command:SpecifyScriptArgs}"
],
"cwd": "${file}",
"name": "PowerShell: Current File",
"request": "launch",
"script": "${file}",
"type": "PowerShell"
},
{
"args": [
"${command:SpecifyScriptArgs}"
],
"name": "PowerShell: Pester",
"request": "launch",
"script": "Invoke-Pester",
"type": "PowerShell"
},
{
"name": "PowerShell: Attach",
"processId": "${command:PickPSHostProcess}",
"request": "attach",
"runspaceId": 1,
"type": "PowerShell"
}
]
}, Is documentation guidance sufficient enough or should the is be an actual commmand palette item to populate something like this in either the user or workspace settings (user choice)? |
I think the generation of this "tasks goo" by this extension would be nice to have. I'm pretty sure this can be done as of tasks 2.0.0. |
I would note that for gherkin style Pester tests that I have a PR (#1276) that will soon be merged to the Pester project. I think I may have mentioned this about a year ago. Things have progressed more slowly than I had hoped—but any day now, it should finally be merged. These style tests will have new problem matchers for them.
In this PR, I also have a tasks.json file that contains many different tasks for running Pester tests, both Rspec style and Gherkin style—I personally use these tasks for running the Pester test suite.
…Sent from my Windows 10 phone
From: Keith Hill
Sent: Friday, April 17, 2020 11:43
To: PowerShell/vscode-powershell
Cc: Craig E. Shea; Mention
Subject: Re: [PowerShell/vscode-powershell] Add support for running Pestertests (#87)
I think the generation of this "tasks goo" by this extension would be nice to have. I'm pretty sure this can be done as of tasks 2.0.0.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
@fourpastmidnight Also, things like this can be added using Set-EditorCommand in modules themselves, maybe it makes sense for Pester to provide a contribution to add the command to auto-populate the task rather than having it be inside the extension? The only drawback that I see there is that it is less discoverable, and also precludes the use of having a toast-style popup "You don't currently have a Pester task defined. Would you like to set up a task for pester?" |
Ah, I didn’t know about this. I’ll have to read up on it and see what can be done!
…Sent from my Windows 10 phone
From: Justin Grote
Sent: Friday, April 17, 2020 13:32
To: PowerShell/vscode-powershell
Cc: Craig E. Shea; Mention
Subject: Re: [PowerShell/vscode-powershell] Add support for running Pestertests (#87)
@fourpastmidnight Also, things like this can be added using Set-EditorCommand in modules themselves, maybe it makes sense for Pester to provide a contribution to add the command to auto-populate the task rather than having it be inside the extension?
The only drawback that I see there is that it is less discoverable, and also precludes the use of having a toast-style popup "You don't currently have a Pester task defined. Would you like to set up a task for pester?"
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
All, Upvote this :) hbenl/vscode-test-explorer#112 (or ya know... Implement one) |
Pester can output NUnit, maybe it can be shimmed somewhat into this extension? |
At some point, I also plan on allowing the Gherkin runner to output Cucumber Json format for told such as Donut.
…Sent from my Windows 10 phone
From: Justin Grote
Sent: Friday, May 29, 2020 10:50
To: PowerShell/vscode-powershell
Cc: Craig E. Shea; Mention
Subject: Re: [PowerShell/vscode-powershell] Add support for running Pestertests (#87)
Pester can output NUnit, maybe it can be shimmed somewhat into this extension?
https://marketplace.visualstudio.com/items?itemName=wghats.vscode-nxunit-test-adapter
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Is this still a requirement now that Tyler made this? |
VSCode is getting a native testing API, maybe it should be open or renamed to target implementation/port of Tylers adapter/etc. to that, not sure? |
I think generally, this issue could be closed because at this rate, I don't know if the PowerShell team will have the bandwidth to reimplement/maintain my extension. Fair enough in my book considering the PowerShell team doesn't maintain Pester itself. I'm happy with my extension being THE Pester extension...although I could always use assistance with maintaining it 😅 With all that said, I think we should sort out a few things before closing this. Short term:
Long term:
None of this work is hard, it's just not a priority which I get. |
@JustinGrote the person who did Test Explorer UI (what my extension uses today) is working with my team on a migration scenario. Once this PR goes in, you'll be able to switch to the new experience without me having to do anything 😁 |
@TylerLeonhardt Now that the PR you mentioned went in, can we mark this issue as resolved? |
This can be closed, I agree with Tyler that even though Pester is considered a "de-facto" part of the ecosystem, it's not something the team supports directly and doesn't need to be owned by the Powershell Team. I've been working on a reimplementation that uses the test APIs natively as an excuse to learn typescript and if it ever gets there I will release it as a standalone option. I don't see any reason this would need to be part of vscode-powershell directly unless it needed to leverage the same PSES instance for whatever reason, but instead probably better the vscode-powershell expose that as an extension API export instead. |
Although related: vscode-powershell provides the codelens for Run Test and Debug Test, and does have a Pester Stub. Should plans be made to deprecate and sunset that functionality? |
There at least needs to be a setting to disable it so I can automatically apply the setting and migrate customers |
Agreed, I'd like to be able to have a popup that says "do you mind if we disable the native Pester codelens?" If this gets marked up-for-grabs I'll consider doing it if mine ever reaches a ready-to-go state. |
opened #3430 |
I'm not exactly sure how to do this but I think it would be nice to have. Maybe this needs to wait for VSCode to have test-runner support (which may never happen)?
The text was updated successfully, but these errors were encountered: