There is more then one way to test it ...
How to test Powershell modules using Perl6 and Tomty
Welcome Tomty
Tomty is a Sparrow6 based testing framework, written in Perl6. We use it to write tests.
Install
zef install Tomty
Usage
Write Powershell module
modules/hello/hello.ps1
function Hello {
param(
[Parameter(Mandatory=$true)]
[String]$name
)
Write-Host Hello $name
}
Write wrapper
mkdir -p .tomty/tasks/test-hello
.tomty/tasks/test-hello/task.ps1
:
Import-Module hello
$name = config 'name'
Hello -name $name
.tom/tasks/test-hello/task.check
:
generator: print "Hello ".( config()->{name} )
Write test
tomty --edit test-hello
task-run ".tomty/tasks/test-hello", %( name => "Sparrow6" )
Run test
PSModulePath=$PWD/modules tomty test-hello
02:47:26 07/27/2019 [repository] index updated from file:///home/melezhik/repo/api/v1/index
02:47:26 07/27/2019 [.tom/tasks/test-hello] Hello Sparrow6
[task check] stdout match <Hello Sparrow6> True
Run more tests
Once you have more tests, you run them all:
tomty --all
See Tomty documentation for other options.
Thank you for reading. I'd appreciate comments.