Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Felix Becker
    @felixfbecker
    Didn’t actually end up using TestDrive though. Just got rid of the error
    currently trying to get codecov working
    Felix Becker
    @felixfbecker
    got it
    Jakub Jareš
    @nohwnd
    gr8
    Alex
    @suprak
    Is it possible to mock the call operator &?
    alx9r
    @alx9r
    I’m not sure. I never have. But I have mocked commands called by the call operator.
    Jowj
    @jowj
    Hello! I'm sort of confused about a problem i'm running into.
    Basically, I'm getting odd behavior when I'm trying to assert that an array is either Empty/Null or NOT empty/null
    https://pastebin.com/wTAt3rCq
    as an example, see that code.
    test-PesterPipelineIssue /Users/me/testingDir/testPester.txt | Should beNullOrEmpty
    if you change that line to "should not beNullOrEmpty"` you'll see the behavior change, which i really don't understand.
    (also, sorry if I'm asking in the wrong place. Please let me know if I should move my question to a different location!)
    Jowj
    @jowj
    aaaand nevermind. I nuked my install of psc and pester and resintalled and now I'm getting different behavior
    Disregard!
    itadder
    @itadder
    heya
    PRASOON KARUNAN V
    @kvprasoon
    Hi Folks,
    Pester gives code coverage for lines, do we have a way to get the same for functions ?
    Jakub Jareš
    @nohwnd
    @kvprasoon No, I don't think there is an option for that.
    PRASOON KARUNAN V
    @kvprasoon
    $Thanks @nohwnd
    bartsaintgermain
    @bartsaintgermain
    hello, anybody used the BeforeEachScenario -Tags statement as described in https://kevinmarquette.github.io/2017-04-30-Powershell-Gherkin-advanced-features/#beforeeachscenario. I get the following error: "The expression after '&' in a pipeline element produced an object that was not valid."
    routhrirajan
    @routhrirajan
    Hello, anybody mocked get-environment variable function either user or machine
    routhrirajan
    @routhrirajan
    I have a function to get environment variable, where I have used Get-EnvironmentVariable function to get the value. While writing pester test, I want to mock [System.Environment]::Get-EnvironmentVariable('XXXX', 'User') inorder to test empty scenario and with value scenrio. Can anyone help on this
    Johan Ljunggren
    @johlju
    @routhrirajan Don't think it is possible to mock that, easiest it to make a wrapper (powershell function) for the method [System.Environment]::GetEnvironmentVariable() and mock that. Another way might be to make a stub class and load with Add-Type, but not sure it works in this case since the type is already loaded.
    routhrirajan
    @routhrirajan
    Thanks @johlju I will try with the suggested options. Let you know if it helps
    Chris Forbes
    @kitforbes
    Hi everyone. How do I test a module that has RequiredModules in the manifest. if the dependent modules are not installed, the tests will fail.
    Chris Forbes
    @kitforbes
    Or this may be due to fully qualified function names, I'm not sure.
    Sotiris Nanopoulos
    @davinci26
    Hey @nohwnd I want to take a stab at this pester/Pester#301 . Is it ok? Is there anyone working on something conflicting with this?
    Rushikesh Vyas
    @ruvyas

    Hey guys I am trying to use Pester (4.8.1) for our azure devops pipeline CI build. I have a "publish test" task and
    this is what I am doing right now
    Invoke-Pester -Script $testFilePath -OutputFile $outputFilePath -OutputFormat 'NUnitXML' -CodeCoverage $psFiles -CodeCoverageOutputFile $codeCoverageOutputFIlePath -EnableExit

    My questions is: Is there a way I can put the result in a variable using passthru and and still save all the outputs in the specified files? I want the task to fail if any tests fail but I also have following tasks that shows test result and I want to see which tests failed. With -EnableExit fail it fails the testing task but it skips publishing test result task too

    Heber Alejandro
    @hebers23_twitter
    Hello everyone! how can I send parameters for each test case in a suite? currently I had just one test case to call and I do it like this Invoke-Pester -Script @{Path = 'C:\Turing\Test\Frida-launcher.ps1'; Parameters = @{frida_process_id = '807028544'; frida_user = 'heber.solis@softtek.com'; frida_psw = 'password'}} -OutputFile "frida-results.xml" -OutputFormat "NUnitXML" but I don't know how to do it for every test case in the suite :(. Thanks for any help :)
    radugrecu
    @radugrecu
    is there a way to escape special characters in gherkin step names?
    i found that trying to use parenthesis or square brackets causes it to stop matching the names of the steps in the features to the names of the actual steps
    I tried escaping these with backslash and and the backtick but still can't get it to work
    Carl in 't Veld
    @cveld
    is there a way to define functions in the scope of a unit test that can be called from a MockWith code block?
    @kitforbes I have a related requirement. I have a custom module that is requiring AzureAD and AD to be imported. But obviously these are very large and I want to leave them out. I just mock all the Azure calls. Currently the only way I manage this is to exclude the required modules from the custom module's manifest psd1 file
    Andy AO
    @Andy-AO
    hello everyone
    I don't feel very active here. There are only 69 members.
    Michael Ablassmeier
    @abbbi
    How is it possible to use Variables for Describe and It blocks in V5? It is not necessarily the -TestCases parameter that helps me out. Im testing various command line tools, each test tool goes into its own file (command.Tests.ps1) so it would be neat to use the "command" as variable from the filename in the it and Describe copes (Descript "test ${command}" ..)
    Using BeforeAll with $global:command="foo" is problematic because if pester is called with -Path on a directory with multiple tests. the global variable overrides during execution all other files too,.. i had weird behavior.
    Daniel Groh
    @dgroh

    I have a function which uses some Azure Cli commands, for example:

        $appRegistration = az ad app create `
            --display-name $name `
            --reply-urls $replyUrls `
            --oauth2-allow-implicit-flow true `
            --available-to-other-tenants false `
            -o json | 
        ConvertFrom-Json

    How can I mock az ad app create and assert the parameters with Assert-MockCalled? I don't find anything about that

    Marc van Gorp
    @Marc013
    @dgroh
    Mocking an executable is not possible. At least not to my knowledge.
    In this scenario I create a 'wrapper' function that calls the executable. This 'wrapper' function can be mocked.
    function Invoke-AzureCli {
        switch ($isWindows) {
            $True {
                $AssertPath = Test-Path -Path 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd'
            }
            $False {
                switch ($IsLinux) {
                    $true {
                        $AssertPath = Test-Path -Path '/usr/bin/az'
                    }
                    Default { throw "Unsuported operating system detected '$PSVersionTable.OS'" }
                }
            }
        }
    
        if ($AssertPath -eq $False) {
            throw "Azure CLI not found!`nThis function requires Azure CLI to be available on this system.`nhttps://docs.microsoft.com/en-us/cli/azure/install-azure-cli"
        }
    
        az $args
    
        if ($LASTEXITCODE -ne 0) {
            throw 'Execution failed'
        }
    }
    Matthew Parsons
    @OranguTech

    (This is only like my second time using Gitter, and first time trying to Pester 5 in ernest)

    The pester.dev documenation isn't clear to me what exactly $PesterPreference is compared to a PesterConfiguration, and why I would want to use one method over the other, or why either are even necessary when I just want to run a test and see the actual output?
    https://pester.dev/docs/usage/configuration#pesterpreference

    1 reply
    stinos
    @stinos
    Just doublechecking before raising an issue: in Pester 5.3 there seems to be no way to get codecoverage parameters like function/startline/endline passed into Pester anymore? The legacy parameter set doesn't accept a hashtable for -CodeCoverage (well it does but it turns it into the string "System.Collections.HashTable" and PesterConfiguration.CodeCoverage only has Paths and enforces that to be a string array. Is this something which is being worked on?
    Miodrag Milić
    @majkinetor
    Hi there, since recently I cant execute tests from vscode, I get this when I click any run/debug
    image.png
    Cannot read property '0' of undefined
    Does anybody know what seems to be the problem ?
    I reinstalled powershell extension just to make sure, but no bueno. Tests work fine when executed outside of vscode
    Using latest Pester, vscode, Powershell extensin, pwsh
    Powershell extension logs show nothing interesting
    Miodrag Milić
    @majkinetor
    Actually found 1 error in Powershell Editor Services
    [Error - 16:32:42] Microsoft.PowerShell.EditorServices.Services.PowerShellContextService: Execution of the following command(s) completed with errors:
    
        Microsoft.PowerShell.Core\Get-Command Send-Ping -ErrorAction Ignore
    
     |
    Anyway, when I remove all the code and leave just Describe 'Pinging' {} it still fails, but without any error
    Miodrag Milić
    @majkinetor
    Here debug log for Powershell editor services , executing empty test from above