Skip to content

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

Closed
rkeithhill opened this issue Feb 6, 2016 · 26 comments
Closed

Add support for running Pester tests #87

rkeithhill opened this issue Feb 6, 2016 · 26 comments
Labels
Area-Tasks Issue-Enhancement A feature request (enhancement). Resolution-Answered Will close automatically. Up for Grabs Will shepherd PRs.

Comments

@rkeithhill
Copy link
Contributor

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)?

@rkeithhill rkeithhill added Issue-Enhancement A feature request (enhancement). Issue-Discussion Let's talk about it. labels Feb 6, 2016
@rkeithhill rkeithhill added this to the Backlog milestone Feb 6, 2016
@daviwil
Copy link
Contributor

daviwil commented Feb 6, 2016

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:

  • Use VS Code's text editor "decoration" support to add some highlighting or gutter icons to show which tests have passed or failed. One good example of doing this is Wallaby.js. Here are some API docs for text decorations.
  • Use VS Code's "Code Lens" support to mark Pester methods with a "Run test" command so that we could invoke test methods directly. Here are some API docs on the Code Lens support. Code Lenses are being used in Visual Studio for stuff like this:

image

Could be an interesting feature to add!

@rkeithhill
Copy link
Contributor Author

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

@TylerLeonhardt
Copy link
Member

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.

@TylerLeonhardt TylerLeonhardt added Area-Tasks and removed Issue-Discussion Let's talk about it. labels Jan 27, 2018
@TylerLeonhardt TylerLeonhardt modified the milestone: Future May 24, 2018
@fourpastmidnight
Copy link

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.)

@TylerLeonhardt
Copy link
Member

@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!

@SydneyhSmith
Copy link
Collaborator

https://code.visualstudio.com/api/references/contribution-points#contributes.taskDefinitions this link shows how to define your own custom tasks

@JustinGrote
Copy link
Collaborator

@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.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Apr 17, 2020
@rkeithhill
Copy link
Contributor Author

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.

@JustinGrote
Copy link
Collaborator

JustinGrote commented Apr 17, 2020

@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)?

@rkeithhill
Copy link
Contributor Author

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.

@fourpastmidnight
Copy link

fourpastmidnight commented Apr 17, 2020 via email

@JustinGrote
Copy link
Collaborator

@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?"

@fourpastmidnight
Copy link

fourpastmidnight commented Apr 17, 2020 via email

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Apr 21, 2020
@TylerLeonhardt
Copy link
Member

All,

Upvote this :) hbenl/vscode-test-explorer#112

(or ya know... Implement one)

@JustinGrote
Copy link
Collaborator

Pester can output NUnit, maybe it can be shimmed somewhat into this extension?
https://marketplace.visualstudio.com/items?itemName=wghats.vscode-nxunit-test-adapter

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label May 29, 2020
@fourpastmidnight
Copy link

fourpastmidnight commented May 29, 2020 via email

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Jun 2, 2020
@SydneyhSmith SydneyhSmith removed this from the Future milestone Jan 26, 2021
@Tiberriver256
Copy link

Is this still a requirement now that Tyler made this?
https://marketplace.visualstudio.com/items?itemName=TylerLeonhardt.vscode-pester-test-adapter

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label May 8, 2021
@JustinGrote
Copy link
Collaborator

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?
https://code.visualstudio.com/api/extension-guides/testing#test-results

@TylerLeonhardt
Copy link
Member

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:

  • we need a way to disable just the Pester CodeLens' provided by the PowerShell extension so that folks can only see the CodeLens from my extension. Today, you end up seeing 5 CodeLens (2 from PS ext, 3 from mine) which is silly and confusing.

Long term:

  • a proper upgrade scenario for discovering my extension. That could include disabling the CodeLens if my extension is installed, and if not installed, and the user is using Pester 5, maybe notify them to check out my extention.

None of this work is hard, it's just not a priority which I get.

@TylerLeonhardt
Copy link
Member

@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 😁

hbenl/vscode-test-explorer#199

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label May 12, 2021
@andyleejordan
Copy link
Member

@TylerLeonhardt Now that the PR you mentioned went in, can we mark this issue as resolved?

@JustinGrote
Copy link
Collaborator

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.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Jun 17, 2021
@andyleejordan andyleejordan added Resolution-Answered Will close automatically. and removed Needs: Maintainer Attention Maintainer attention needed! labels Jun 17, 2021
@JustinGrote
Copy link
Collaborator

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?

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Jun 17, 2021
@TylerLeonhardt
Copy link
Member

There at least needs to be a setting to disable it so I can automatically apply the setting and migrate customers

@JustinGrote
Copy link
Collaborator

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.

@ghost ghost closed this as completed Jun 18, 2021
@TylerLeonhardt
Copy link
Member

opened #3430

@andyleejordan andyleejordan removed the Needs: Maintainer Attention Maintainer attention needed! label Jul 20, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Tasks Issue-Enhancement A feature request (enhancement). Resolution-Answered Will close automatically. Up for Grabs Will shepherd PRs.
Projects
None yet
Development

No branches or pull requests

8 participants