【问题标题】:Jenkins job dsl and MSTest integrationJenkins job dsl 和 MSTest 集成
【发布时间】:2016-01-08 12:48:16
【问题描述】:

Jenkins Job DSL 插件是一种将 CI 配置存储在 repo 中并在分支之间改变它的非常好的方法。

问题是 - 是否有一种自然或接近自然的方式来运行 MSTest 测试、解析结果并显示它们。

现在我进行了一个 powershell 调用,但它只给了我日志,而不是 UI 集成。

def testSomeProjectJob =  job(testSomeProjectJobName) {
    steps { 
      powerShell("& ${vstest} '${root}/SomeProject/SomeProject.Tests/bin/Debug/SomeProject.Tests.dll' ")
    }
}

可能有发布者或模板技巧,或者为此编写 JOB DSL 插件的一些技巧


UPD:MSTest 和 VSTest 的最终脚本模板,使用 @daspilker answer、jenkins xUnit PluginarchiveXUnit

  job('RunTests') {
      steps {
           // VSTEST
           powerShell("& ${vstest} 'path/to/Tests.dll' /logger:trx ")
           // Or MSBUILD
            powerShell("& ${msbuild} /testcontainer:'path/to/Tests.dll' ")
      }
      publishers {
        archiveXUnit {
          msTest {
            pattern('**/*.trx')
            // deleteOutputFiles()
          }
        }
      }
    }

【问题讨论】:

    标签: jenkins jenkins-plugins mstest jenkins-job-dsl jenkins-mstest


    【解决方案1】:

    使用 PowerShell 步骤是一个好的开始。安装xUnit Plugin 以解析并显示结果。它可以解析包括 MSTest 在内的各种测试结果。并且您可以使用DSL 来配置插件。

    例子:

    job('example') {
      steps {
        powerShell('...')
      }
      publishers {
        archiveXUnit {
          msTest {
            pattern('path/to/test/results')
          }
        }
      }
    }
    

    【讨论】:

      【解决方案2】:

      它用于 VSTest,但我最终必须使用配置块才能在 DSL 作业中使用它。

      static Closure useVsTest(List<String> dlls) { return { it / 'builders' << 'org.jenkinsci.plugins.vstest__runner.VsTestBuilder' { vsTestName 'VS 14.0' testFiles dlls.join('\n') settings '' testCaseFilter '' enablecodecoverage false useVsixExtensions true platform 'x86' otherPlatform '' framework 'framework45' otherFramework '' logger 'trx' otherLogger '' cmdLineArgs '/TestAdapterPath:"."' failBuild true } } }

      【讨论】:

      • 非常好用!
      猜你喜欢
      • 1970-01-01
      • 2020-02-06
      • 1970-01-01
      • 2018-04-22
      • 1970-01-01
      • 2015-03-25
      • 1970-01-01
      • 2022-08-15
      • 1970-01-01
      相关资源
      最近更新 更多