ModuleBuilder icon indicating copy to clipboard operation
ModuleBuilder copied to clipboard

Add Tests for Function Exports

Open markekraus opened this issue 7 years ago • 4 comments
trafficstars

As a ModuleBuilder user In order to ensure expectations I need shared tests that validate inputs and outputs


We should create common test cases

  • Test all exported functions came from separate files
  • Test all public functions are properly exported by the module
  • Test only public functions are exported by the module

markekraus avatar Apr 14 '18 17:04 markekraus

NOTE: these tests need to ship with the module, and shouldn't be confused with the unit tests which also need to verify that this happens in order to prove that our code actually does the right thing.

Jaykul avatar May 04 '18 17:05 Jaykul

have a look into https://github.com/PowerShellModules/PesterHelpers/ as there may be some overlaps / enhancements there that can be brought in for this

kilasuit avatar May 19 '18 03:05 kilasuit

On the chance this goes in the direction you're after I've got some tests written to help ensure the module is loading properly at https://github.com/Rick-2CA/MDSTools/blob/master/Tests/Unit.GenericModule.Tests.ps1. Seems to go in the direction the issue is after. I'd be interested in putting more work into it to better serve the project if the approach is close enough to build off of.

Rick-2CA avatar Jun 15 '18 14:06 Rick-2CA

I just found this issue and wanted to add my 2 cents.

I have a lot of functions where I use the manifest's DefaultCommandPrefix. So I need to consider a dynamic prefix in the command names. And therefore I wrote my tests like this: https://github.com/AtlassianPS/AtlassianPS.Configuration/blob/master/Tests/Project.Tests.ps1#L41-L58

As far as I can tell (and have tested), this works perfectly on modules that don't use DefaultCommandPrefix.

lipkau avatar Aug 11 '18 11:08 lipkau