Как передать параметры для каждого теста в pester? - PullRequest
2 голосов
/ 19 февраля 2020

У меня есть сценарий powershell в 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"

, который вызывает другой сценарий powershell на компьютере, где работает конвейер

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 
    }
}

, проблема в том, что до сих пор у меня есть нужно было только запустить один тестовый набор, но теперь мне нужно запустить набор тестов, но я не знаю, как отправить параметры каждого тестового примера.

Я пытался сделать это следующим образом

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"

, но выдает эту ошибку

"C: \ Windows \ System32 \ WindowsPowerShell \ v1.0 \ powershell.exe" -NoLogo -NoProfile -NonInteractive - ExecutionPolicy Неограниченная команда 99 + ... ida_user = 'heber. solis@softtek.com'; frida_psw = 'password'}} -Outpu ... + ~ Отсутствует оператор '=' после ввода литерала ha sh. В C: \ agent_work_temp \ 67c2cb15-7277-43ea-a21e-c1a5aaab3309.ps1: 3 char: 99 + ... ida_user = 'heber. solis@softtek.com'; frida_psw = 'password'}} -Outpu ... + ~ Литерал ha sh был неполным. + CategoryInfo: ParserError: (:) [], ParseException + FullyQualifiedErrorId: MissingEqualsInHashLiteral

[ошибка] PowerShell завершил работу с кодом '1'. Отделка: PowerShell Script

спасибо за помощь

...