如何使用四个标准参数的Pester V5配置或容器?

发布于 2025-01-28 06:00:32 字数 799 浏览 4 评论 0原文

我正在尝试调用佩斯特脚本,从佩斯特v4.6.0到v5.3.1

我曾经使用的v4参数时,当调用佩斯特时:

-supplying custom parameters
-OutputFormat NUnitXML
-OutputFile $xmlpath
-EnableExit

但是,对于v5,我需要使用配置或使用配置或调用佩斯特一个容器,两个都没有完全满足我在V4中使用的参数。限制似乎是:

Invoke -Pester -Configuration $ Pesterconfig $ pesterconfig不喜欢我指定自定义数据参数的地方,例如: data = @{datafactoryname = $ datafactoryname;}

invoke -pester -container $ container -eroraction stop -output详细信息-CI $容器不喜欢我指定的地方: - 输出format nunitxml -outputfile $ xmlPath - EnableExit

我如何更有效地使用容器或配置,以允许我指定以下4件:

-supplying custom parameters
-OutputFormat NUnitXML
-OutputFile $xmlpath
-EnableExit

一项工作,是为了解决使用配置,它可以满足我的4个参数中的3个,然后将自定义数据传递给一个文件或Env变量,并在调用的PS脚本中读取它。虽然可能不是理想的。

I'm trying to invoke a pester script, moving from pester V4.6.0 to V5.3.1

The V4 arguments I used to use, when invoking pester were:

-supplying custom parameters
-OutputFormat NUnitXML
-OutputFile $xmlpath
-EnableExit

However, it seems for v5, I need to invoke Pester using either a configuration OR a container, neither of which cater fully for the arguments I used in V4. The limitations seem to be:

Invoke-Pester -Configuration $pesterConfig
where $pesterConfig doesn't like me specifying custom data params in it, eg:
Data = @{dataFactoryName = $dataFactoryName;}

or

Invoke-Pester -Container $container -ErrorAction Stop -Output Detailed -CI
where $container doesn't like me specifying:
-OutputFormat NUnitXML
-OutputFile $xmlpath
-EnableExit

How can I more efficiently use either container or configuration, to allow me to specify the following 4 things:

-supplying custom parameters
-OutputFormat NUnitXML
-OutputFile $xmlpath
-EnableExit

One work around, would be to settle for using configuration, which caters for 3 of my 4 arguments, and pass custom data to a file or env variable and read it in within the invoked ps script. Probably not ideal though.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

记忆で 2025-02-04 06:00:32

找到了将配置和容器一起使用的方法:

        $container = New-PesterContainer -Path "..." -Data @{
            customParamA= "value"; 
            customParamB= "value"; 
        }

        $pesterConfig = [PesterConfiguration]@{
            Run = @{
                Exit = $true
                Container = $container
            }
            Output = @{
                Verbosity = 'Detailed'
            }
            TestResult = @{
                Enabled      = $true
                OutputFormat = "NUnitXml"
                OutputPath   = $xmlpath
            }
            Should = @{
                ErrorAction = 'Stop'
            }
        }

        Invoke-Pester -Configuration $pesterConfig

Found a way to use configuration and container together:

        $container = New-PesterContainer -Path "..." -Data @{
            customParamA= "value"; 
            customParamB= "value"; 
        }

        $pesterConfig = [PesterConfiguration]@{
            Run = @{
                Exit = $true
                Container = $container
            }
            Output = @{
                Verbosity = 'Detailed'
            }
            TestResult = @{
                Enabled      = $true
                OutputFormat = "NUnitXml"
                OutputPath   = $xmlpath
            }
            Should = @{
                ErrorAction = 'Stop'
            }
        }

        Invoke-Pester -Configuration $pesterConfig
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文