Skip to content
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

CommandNotFoundException only in AzureDevops #55

Open
FelixBrunet opened this issue Jan 8, 2021 · 2 comments
Open

CommandNotFoundException only in AzureDevops #55

FelixBrunet opened this issue Jan 8, 2021 · 2 comments
Assignees

Comments

@FelixBrunet
Copy link

FelixBrunet commented Jan 8, 2021

Where are you running it?

  • Azure DevOps Service (VSTS)

Expected behaviour and actual behaviour

CommandNotFoundException: Could not find Command PSIISReset

I import with in Tests.ps1
. "$PSScriptRoot..\ArielDbCore\IISOperations.ps1"

	Mock -CommandName PSIISReset -MockWith { 
			Write-Output "Called fake PSIISReset"
		}

My pipeline :

  • task: Pester@10
    inputs:
    scriptFolder: "$(System.DefaultWorkingDirectory)\ArielDb-Orchestrator\Tests.ps1"
    resultsFile: "$(System.DefaultWorkingDirectory)\Test-Pester-ArielDb-Orchestrator.XML"
    CodeCoverageOutputFile: "$(System.DefaultWorkingDirectory)\ArielDb-OrchestratorCoverage.XML"
    usePSCore: False
    CodeCoverageFolder: "$(System.DefaultWorkingDirectory)\ArielDb-Orchestrator"
    preferredPesterVersion: '5.0.4'
    additionalModulePath: '$(System.DefaultWorkingDirectory)\ArielDb-Orchestrator'

Steps to reproduce the problem

It run fine on my machine using pester 5.0.4 but not with AzureDevops
I try setting 32bit=true, switching from importmodule to dotsourcing, preferredPesterVersion , additionalModulePath (which is not the good one right now, I dont have only one path for all import)

I think it's because i used powershell v5.1 on my machine, and remote is 7.1 ?

@ChrisLGardner
Copy link
Collaborator

Azure DevOps will default to Windows PowerShell (5.1) and ony use PowerShell (7.x) when you specify the usePSCore option to true.

Can you share some more of your tests file? Where are you declaring the mock? Where are you doing the import/dotsourcing?

@ChrisLGardner ChrisLGardner self-assigned this Jan 9, 2021
@FelixBrunet
Copy link
Author

I found it today
This was working with debugger but not with Invoke-Pester , i fix it placing import in BeforeAll. When you have no beforeall , it run fine using Tests.ps1 but not with Invoke-Pester

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants