pester / Pester

Pester is the ubiquitous test and mock framework for PowerShell.
https://pester.dev/
Other
3.11k stars 473 forks source link

Error running bin\pester.bat with PowerShell 2.0 #130

Closed nfisher closed 10 years ago

nfisher commented 10 years ago

Background

When running bin\pester.bat on a Windows 7 dev machine it fails to execute correctly, instead failing with an error regarding unsigned scripts as illustrated in Actual Results below.

System Details

Windows 7 Professional SP1

$Host.Version

Major  Minor  Build  Revision
-----  -----  -----  --------
2      0      -1     -1

Steps to Reproduce

  1. Clone pester repo to %CLONE_DIR%.
  2. Open powershell command prompt as local user.
  3. cd %CLONE_DIR%
  4. Run bin\pester.bat

    Expected Results

Pester runs tests with the following output;

Describing Add-Numbers
 [+] adds positive numbers 5ms
 [+] adds negative numbers 1ms
 [+] adds one negative number to positive number 2ms
 [+] concatenates strings if given strings 2ms
 [+] should not be 0 2ms
Describing Testing a validator
 [+] calls MyValidator 110ms
Describing MyValidator
 [+] passes things that start with the letter S 3ms
 [+] does not pass a param that does not start with S 2ms
Describing Write nunit test results
 [+] should write a successful test result 455ms
 [+] should write a failed test result 102ms
 [+] should write the test summary 109ms
 [+] should write the test-suite information 180ms
 [+] should write two test-suite elements for two describes 221ms
 [+] should write the environment information 88ms
 [+] Should validate test results against the nunit 2.5 schema 74ms
Describing Get-TestTime
 [+] output is culture agnostic 16ms
 [+] Time is measured in seconds with 0,1 millisecond as lowest value 11ms
Describing Replacing strings
 [+] should remove powershell backtick when replacing strings 2ms
 [+] should remove single quote when replacing strings 2ms
Describing Templating
 [+] Should get a template from the template folder 38ms
 [+] Should replace strings in template with the according value 13ms
Describing It
 [+] records the correct stack line number of failed tests 21ms
 [+] should pass if assertions pass 1ms
 [+] throws if no test block given 10ms
 [+] test block 0ms
 [+] won't throw if success test block given 10ms
 [+] tests 3ms
 [+] Does not rewrite Test variable 7ms
 [+] does not override the pester variable 0ms
-- snip --

Actual Results

Import-Module : File E:\Pester\Pester.psm1 cannot be loaded. The file E:\Pester\Pester.psm1 is not digitally signed. Th
e script will not execute on the system. Please see "get-help about_signing" for more details..
At line:1 char:2
+ & <<<<  Import-Module 'E:\Pester\bin\..\Pester.psm1'; & { Invoke-Pester -OutputXml Test.xml -EnableExit }
    + CategoryInfo          : NotSpecified: (:) [Import-Module], PSSecurityException
    + FullyQualifiedErrorId : RuntimeException,Microsoft.PowerShell.Commands.ImportModuleCommand

The term 'Invoke-Pester' is not recognized as the name of a cmdlet, function, script file, or operable program. Check t
he spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:66
+ & Import-Module 'E:\Pester\bin\..\Pester.psm1'; & { Invoke-Pester <<<<  -OutputXml Test.xml -EnableExit }
    + CategoryInfo          : ObjectNotFound: (Invoke-Pester:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Aka sux to be you!!! lolz

scottmuc commented 10 years ago

Strange! The whole point about adding the -ExecutionPolicy parameter is to handle that very situation.