2

I have a powershell script in azure

Invoke-Pester -Script @{Path = 'C:\Turing\Test\Frida-launcher.ps1'; Parameters = @{frida_process_id = '1655944245'; frida_user = 'heber.solis@softtek.com'; frida_psw = 'password'}} -OutputFile "frida-results.xml" -OutputFormat "NUnitXML"

which calls another powershell script on the machine where the pipeline runs

param($frida_process_id, $frida_user, $frida_psw)
"current location: $(Get-Location)"
"script root: $PSScriptRoot"
"retrieve available modules"
$modules = Get-Module -list
if ($modules.Name -notcontains 'pester') {
    Install-Module -Name Pester -Force -SkipPublisherCheck
}

#$frida_process_id = $args[0]
#$frida_user = $args[1]
#$frida_psw  = $args[2]



Describe "Suites - Prueba" {

    It "Test Case Script - HEB - FRIDA - eCommerce - 706161449 _ Conexion Exitosa " {

        Start-Process -FilePath "C:\Turing\App\TuringExpo.exe"  "$frida_process_id $frida_user $frida_psw"  -Wait
        Set-Content -Path TestDrive:\log.txt -Value 'I am a file'
        $actual = "Actual value"
        $actual | Should -Be "Actual value" # Test will pass / Assert 
        $actual | Should -Not -Be "Some other value" # Test will pass / Assert Negative 
        # $actual | Should -Be "not actual value"  # Test will fail
        'C:\Turing\App\log.txt' | Should -Exist
        Set-Content -Path TestDrive:\log.txt -Value 'Success'
        'TestDrive:\log.txt' | Should -FileContentMatch 'Success' # Test will pass 
    }
}

the problem is that so far I have only had the need to run a single test case, but now, I need to run a test suite but I don't know how to send the parameters of each test case.

I tried to 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'}
@{frida_process_id = '1354584657'; frida_user = 'heber.solis@softtek.com'; frida_psw = 'password'}} -OutputFile "frida-results.xml" -OutputFormat "NUnitXML"

but it threw this error

"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'C:\agent_work_temp\67c2cb15-7277-43ea-a21e-c1a5aaab3309.ps1'" At C:\agent_work_temp\67c2cb15-7277-43ea-a21e-c1a5aaab3309.ps1:3 char:99 + ... ida_user = 'heber.solis@softtek.com'; frida_psw = 'password'}} -Outpu ... + ~ Missing '=' operator after key in hash literal. At C:\agent_work_temp\67c2cb15-7277-43ea-a21e-c1a5aaab3309.ps1:3 char:99 + ... ida_user = 'heber.solis@softtek.com'; frida_psw = 'password'}} -Outpu ... + ~ The hash literal was incomplete. + CategoryInfo : ParserError: (:) [], ParseException + FullyQualifiedErrorId : MissingEqualsInHashLiteral

[error]PowerShell exited with code '1'. Finishing: PowerShell Script

thank you for your help

Heber Solis
  • 437
  • 1
  • 6
  • 15
  • The documentation here - https://pester.dev/docs/commands/It#example-2 - shows one way of defining test cases. It provides the test case data inline in your test script rather than as parameters to Invoke-Pester but maybe you can use that approach instead. – mclayton Feb 23 '20 at 04:13

0 Answers0