Powershell Studio 5.4.136
Hi Folks,
Has anyone had any success designing Pshell studio winform apps and using pester for testing?
Pshell studio has been great for us for implementing some LOB CRUD apps that would otherwise have taken much more work to implement in C#. We would like to integrate use of pester for unit testing into our dev process but it just seems so incredibly awkward to do that with event driven programming paradigm of winform api.
Anyone have any experience they can share about how to do that effectively? Maybe pull as much as possible of the business logic out of the form ps1 into modules or libraries, pass data objects in and out as params, and use pester on those external libraries?
thanks,
LT
Design of pstudio winforms apps re. pester
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- LtMandella
- Posts: 61
- Last visit: Mon May 07, 2018 4:03 pm
Re: Design of pstudio winforms apps re. pester
I moved this topic to the PowerShell GUIs forum so that other can respond.
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: Design of pstudio winforms apps re. pester
See these blog posts for some pointers.
https://www.sapien.com/blog/?s=pester
Eventually Pester may be integrated with PSS...maybe.
https://www.sapien.com/blog/?s=pester
Eventually Pester may be integrated with PSS...maybe.
- LtMandella
- Posts: 61
- Last visit: Mon May 07, 2018 4:03 pm
Re: Design of pstudio winforms apps re. pester
thanks JV!
[[Eventually Pester may be integrated with PSS...maybe.]]
That would be _awesome_!!
[[Eventually Pester may be integrated with PSS...maybe.]]
That would be _awesome_!!
Re: Design of pstudio winforms apps re. pester
Don't quote me on that. It is just an assumption that, if it is possible, it would be useful. For now use the Pester CmdLets.LtMandella wrote: ↑Mon Nov 13, 2017 3:10 pm thanks JV!
[[Eventually Pester may be integrated with PSS...maybe.]]
That would be _awesome_!!
Also do this:
Code: Select all
PS D:\scripts> find-module *pester*
Version Name Repository
------- ---- ----------
4.0.8 Pester PSGallery
1.5.1 Format-Pester PSGallery
0.3.1 PesterMatchArray PSGallery
0.0.6 PesterHelpers PSGallery
0.3.0 PesterMatchHashtable PSGallery
- LtMandella
- Posts: 61
- Last visit: Mon May 07, 2018 4:03 pm
Re: Design of pstudio winforms apps re. pester
thank you again!
Does seem like I will need to move much of the the logic in the winform event related logic into functions in separate file if I want to unit test using pester.
Then just . source the function file so the winform event handlers can reference the appropriate logic in the functions.
Of course that is still better than what I am doing now, which is just running the complete app for testing, and not really unit testing at all.
Does seem like I will need to move much of the the logic in the winform event related logic into functions in separate file if I want to unit test using pester.
Then just . source the function file so the winform event handlers can reference the appropriate logic in the functions.
Of course that is still better than what I am doing now, which is just running the complete app for testing, and not really unit testing at all.
Re: Design of pstudio winforms apps re. pester
An event is a function. It is an anonymous function. In PowerShell a function is really a named scriptblock. An event can take a function pointer (delegate) and it can be named or anonymous.
Just tell Pester to test eh function.
Just tell Pester to test eh function.
- LtMandella
- Posts: 61
- Last visit: Mon May 07, 2018 4:03 pm
Re: Design of pstudio winforms apps re. pester
Thanks, my first step will be to read through that blog and work through some pester tutorials.
The goal is to be able execute an external test script that would test functions in the separate winform application .ps1
And I would not want to have any test related artifacts residing in the application .ps1 even if it is just test related parameters.
The goal is to be able execute an external test script that would test functions in the separate winform application .ps1
And I would not want to have any test related artifacts residing in the application .ps1 even if it is just test related parameters.
Re: Design of pstudio winforms apps re. pester
Pester is open source. You could modify it to extract and apply tests to scriptblocks. This would avoid unnecessary design changes to how a form is built.
The current version of Pester does not assume event driven issues so it may not work when the functions are called from a form as the variables I a function can be changed by another event under certain circumstances and pester may not assume this.
The current version of Pester does not assume event driven issues so it may not work when the functions are called from a form as the variables I a function can be changed by another event under certain circumstances and pester may not assume this.