【问题标题】:Running automated Powershell-NUnit tests on TeamCity在 TeamCity 上运行自动化 Powershell-NUnit 测试
【发布时间】:2012-07-19 04:24:22
【问题描述】:

我发现了一种在 Powershell 中使用 NUnit 的巧妙方法。 http://elegantcode.com/2009/10/25/integration-test-brought-to-you-by-powershell-nunit-with-a-little-specification-syntax-for-flavoring/ 我们在很多测试中都使用它。

但是我想在 TeamCity 中运行这些测试。 当我们使用 NUnit 运行器在 TeamCity 中运行 C# 测试时,我想要类似的行为,即当测试执行失败时构建失败。你们有没有人做到这一点?我怀疑 Powershell 运行程序只会将它作为一个简单的脚本执行,而没有任何迹象表明测试是通过还是失败。

【问题讨论】:

    标签: c# powershell nunit teamcity


    【解决方案1】:

    【讨论】:

    • 您对 Powershell runner 问题是完全正确的。我们从 cmd 行运行器运行它,似乎没有遇到这个问题。
    【解决方案2】:

    我不熟悉您在 TeamCity 中通过 Powershell 执行 NUnit 测试所引用的方法。但是,我们成功地将PSake 用于 Powershell 构建脚本,包括执行 NUnit 测试和适当地使构建失败。带有退出代码的 PSake 和 TeamCity 也存在同样的问题,但您可以通过使用 -Command 执行脚本在构建步骤的脚本源中指定 TeamCity 来解决此问题:

    import-module .\tools\psake\psake.psm1
    $psake.use_exit_on_error = $true
    invoke-psake build.ps1 
    remove-module psake
    

    您还可以使用 TeamCity 构建步骤中的构建功能选项将测试结果集成到 TeamCity。

    【讨论】:

      猜你喜欢
      • 2011-09-14
      • 1970-01-01
      • 1970-01-01
      • 2013-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多