powershell - 如何在纠缠中为每个测试用例传递参数?
问题描述
我在 azure 中有一个 powershell 脚本
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 Unrestricted -Command "。'C:\agent_work_temp\67c2cb15-7277-43ea-a21e-c1a5aaab3309.ps1'"在 C:\agent_work_temp\67c2cb15-7277-43ea-a21e-c1a5aaab3309.ps1:3 char:99 + ... ida_user = 'heber.solis@softtek.com'; frida_psw = 'password'}} -Outpu ... + ~ 在散列文字中的键后缺少“=”运算符。在 C:\agent_work_temp\67c2cb15-7277-43ea-a21e-c1a5aaab3309.ps1:3 char:99 + ... ida_user = 'heber.solis@softtek.com'; frida_psw = 'password'}} -Outpu ... + ~ 哈希文字不完整。+ CategoryInfo : ParserError: (:
[错误]PowerShell 以代码“1”退出。整理:PowerShell脚本
谢谢您的帮助
解决方案
推荐阅读
- javascript - 循环内部的对象与外部不同
- mysql - mysqli_real_connect(): (HY000/1524): Xampp Windows 10 中未加载插件“unix_socket”
- javascript - 更新位置后 D3 强制链接未与节点连接
- angular - Angular 数据绑定与引用类型
- javascript - 当我尝试从 Firestore 收集时出现问题
- javascript - 需要读取安全cookie并需要检查它是否存在
- angular - binding.node 不是有效的 Win32 应用程序
- google-cloud-platform - 如何使用“gsutil”复制文件夹?
- javascript - 计算 100 分中的 XP 完成百分比
- php - Azure 存储帐户位置变量/常量在哪里